Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of internal df_explicit_na #1023

Merged
merged 10 commits into from
Aug 14, 2023
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Miscellaneous
* Fix swapped descriptions for the `.N_row` and `.N_col` parameters.
* Fix bug in `analyze_vars_in_cols` when categorical data was used.
* Removal of internal calls to `df_explicit_na`. Changes in `NA` values should happen externally to `tern` functions, depending on users' needs.

# tern 0.8.5

Expand Down
1 change: 0 additions & 1 deletion R/h_adsl_adlb_merge_using_worst_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ h_adsl_adlb_merge_using_worst_flag <- function(adsl, # nolint
adlb_out$ATOXGR <- as.factor(adlb_out$ATOXGR)
adlb_out$BTOXGR <- as.factor(adlb_out$BTOXGR)

adlb_out <- df_explicit_na(adlb_out)
formatters::var_labels(adlb_out) <- adlb_var_labels

adlb_out
Expand Down
3 changes: 0 additions & 3 deletions R/h_stack_by_baskets.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ h_stack_by_baskets <- function(df,
keys = c("STUDYID", "USUBJID", "ASTDTM", "AEDECOD", "AESEQ"),
aag_summary = NULL,
na_level = "<Missing>") {
# Use of df_explicit_na() in case the user has not previously used
df <- df_explicit_na(df, na_level = na_level)

smq_nam <- baskets[startsWith(baskets, "SMQ")]
# SC corresponding to NAM
smq_sc <- gsub(pattern = "NAM", replacement = "SC", x = smq_nam, fixed = TRUE)
Expand Down
15 changes: 8 additions & 7 deletions tests/testthat/test-h_adsl_adlb_merge_using_worst_flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ testthat::test_that("h_adsl_adlb_merge_using_worst_flag generates missing for pa
adlb_f <- tern_ex_adlb %>%
dplyr::filter(USUBJID %in% c("AB12345-CHN-3-id-128"))

result <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c("WGRHIFL" = "Y"))

res <- testthat::expect_silent(result)
testthat::expect_silent(
result <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c("WGRHIFL" = "Y"))
)
res <- df_explicit_na(result)
testthat::expect_snapshot(res)
})

Expand All @@ -20,7 +21,7 @@ testthat::test_that("h_adsl_adlb_merge_using_worst_flag generates missing for pa

result <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c("WGRHIFL" = "Y"))

res <- testthat::expect_silent(result)
res <- df_explicit_na(result)
testthat::expect_snapshot(res)
})

Expand All @@ -34,7 +35,7 @@ testthat::test_that("h_adsl_adlb_merge_using_worst_flag generates missing for pa

result <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c("WGRHIFL" = "Y"))

res <- testthat::expect_silent(result)
res <- df_explicit_na(result)
testthat::expect_snapshot(res)
})

Expand All @@ -50,7 +51,7 @@ testthat::test_that(

result <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c("WGRHIFL" = "Y"))

res <- testthat::expect_silent(result)
res <- df_explicit_na(result)
testthat::expect_snapshot(res)
}
)
Expand All @@ -63,6 +64,6 @@ testthat::test_that("h_adsl_adlb_merge_using_worst_flag generates missing and by

result <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c("WGRHIVFL" = "Y"), by_visit = TRUE)

res <- testthat::expect_silent(result)
res <- df_explicit_na(result)
testthat::expect_snapshot(res)
})
1 change: 1 addition & 0 deletions tests/testthat/test-h_stack_by_baskets.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Local data pre-processing
adae_local <- tern_ex_adae[1:20, ] %>% df_explicit_na()
adae_local[1, ] <- NA

testthat::test_that("h_stack_by_baskets returns the correct dataframe", {
result <- h_stack_by_baskets(df = adae_local) %>% data.frame()
Expand Down