diff --git a/DESCRIPTION b/DESCRIPTION index fc7682cbc5..c2449f2a95 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tern Title: Create Common TLGs Used in Clinical Trials -Version: 0.7.10 +Version: 0.7.10.9000 Date: 2022-10-14 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index 41d64c1e62..f92f41c88f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# tern 0.7.10.9000 + +### Enhancements +* Replaced `synthetic_cdisc_data` with refactored `synthetic_cdisc_dataset` function to speed up dataset loading in tests/examples. +* Updated all tests to use `rcd_2022_06_27` version of cached data. + # tern 0.7.10 ### New Features diff --git a/R/abnormal_by_worst_grade.R b/R/abnormal_by_worst_grade.R index 4cb05ae4fc..795cdac50c 100644 --- a/R/abnormal_by_worst_grade.R +++ b/R/abnormal_by_worst_grade.R @@ -36,8 +36,7 @@ NULL #' library(scda) #' library(dplyr) #' library(forcats) -#' -#' adlb <- synthetic_cdisc_data("latest")$adlb +#' adlb <- synthetic_cdisc_dataset("latest", "adlb") #' #' # Data is modified in order to have some parameters with grades only in one direction #' # and simulate the real data. diff --git a/R/abnormal_by_worst_grade_worsen.R b/R/abnormal_by_worst_grade_worsen.R index 043cbf9a87..5acc5fd144 100644 --- a/R/abnormal_by_worst_grade_worsen.R +++ b/R/abnormal_by_worst_grade_worsen.R @@ -33,11 +33,10 @@ NULL #' for the high direction. #' #' @examples -#' #' library(scda) #' library(dplyr) -#' adlb <- synthetic_cdisc_data("latest")$adlb -#' adsl <- synthetic_cdisc_data("latest")$adsl +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") +#' adlb <- synthetic_cdisc_dataset("latest", "adlb") #' #' # The direction variable, GRADDR, is based on metadata #' adlb <- adlb %>% diff --git a/R/count_cumulative.R b/R/count_cumulative.R index ff7bbe19aa..275853dac3 100644 --- a/R/count_cumulative.R +++ b/R/count_cumulative.R @@ -46,13 +46,13 @@ h_count_cumulative <- function(x, checkmate::assert_flag(na.rm) is_keep <- if (na.rm) !is.na(x) else rep(TRUE, length(x)) - count <- if (lower_tail & include_eq) { + count <- if (lower_tail && include_eq) { length(x[is_keep & x <= threshold]) - } else if (lower_tail & !include_eq) { + } else if (lower_tail && !include_eq) { length(x[is_keep & x < threshold]) - } else if (!lower_tail & include_eq) { + } else if (!lower_tail && include_eq) { length(x[is_keep & x >= threshold]) - } else if (!lower_tail & !include_eq) { + } else if (!lower_tail && !include_eq) { length(x[is_keep & x > threshold]) } @@ -137,7 +137,8 @@ a_count_cumulative <- make_afun( #' @export #' @examples #' library(scda) -#' ADSL <- synthetic_cdisc_data("latest")$adsl +#' ADSL <- synthetic_cdisc_dataset("latest", "adsl") +#' #' basic_table() %>% #' split_cols_by("ARM") %>% #' add_colcounts() %>% @@ -146,6 +147,7 @@ a_count_cumulative <- make_afun( #' thresholds = c(40, 60) #' ) %>% #' build_table(ADSL) +#' count_cumulative <- function(lyt, vars, var_labels = vars, diff --git a/R/count_missed_doses.R b/R/count_missed_doses.R index b0d2b9828f..69564ca115 100644 --- a/R/count_missed_doses.R +++ b/R/count_missed_doses.R @@ -92,8 +92,9 @@ a_count_missed_doses <- make_afun( #' @examples #' library(dplyr) #' library(scda) -#' adex <- synthetic_cdisc_data("latest")$adex -#' adsl <- synthetic_cdisc_data("latest")$adsl +#' adex <- synthetic_cdisc_dataset("latest", "adex") +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") +#' #' anl <- adex %>% #' distinct(STUDYID, USUBJID, ARM) %>% #' mutate( diff --git a/R/count_patients_with_event.R b/R/count_patients_with_event.R index 84aa4875cc..779ccd0b60 100644 --- a/R/count_patients_with_event.R +++ b/R/count_patients_with_event.R @@ -26,12 +26,10 @@ NULL #' @export #' #' @examples -#' -#' #' library(dplyr) #' library(scda) -#' adae <- synthetic_cdisc_data("latest")$adae -#' adsl <- synthetic_cdisc_data("latest")$adsl +#' adae <- synthetic_cdisc_dataset("latest", "adae") +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") #' #' # `s_count_patients_with_event()` #' diff --git a/R/coxph.R b/R/coxph.R index 9089346286..4c06bb8367 100644 --- a/R/coxph.R +++ b/R/coxph.R @@ -91,18 +91,18 @@ rht <- function(x) { #' library(scda) #' library(survival) #' -#' ADSL <- synthetic_cdisc_data("latest")$adsl +#' ADSL <- synthetic_cdisc_dataset("latest", "adsl") #' ADSL <- ADSL %>% #' filter(SEX %in% c("F", "M")) #' -#' ADTTE <- synthetic_cdisc_data("latest")$adtte %>% +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "PFS") -#' ADTTE$ARMCD <- droplevels(ADTTE$ARMCD) -#' ADTTE$SEX <- droplevels(ADTTE$SEX) +#' adtte$ARMCD <- droplevels(adtte$ARMCD) +#' adtte$SEX <- droplevels(adtte$SEX) #' #' mod <- coxph( #' formula = Surv(time = AVAL, event = 1 - CNSR) ~ (SEX + ARMCD)^2, -#' data = ADTTE +#' data = adtte #' ) #' #' mmat <- stats::model.matrix(mod)[1, ] @@ -299,7 +299,7 @@ check_formula <- function(formula) { check_covariate_formulas <- function(covariates) { - if (!all(vapply(X = covariates, FUN = inherits, what = "formula", FUN.VALUE = TRUE)) | is.null(covariates)) { + if (!all(vapply(X = covariates, FUN = inherits, what = "formula", FUN.VALUE = TRUE)) || is.null(covariates)) { stop("Check `covariates`, it should be a list of right-hand-term formulas, e.g. list(Age = ~AGE).") } @@ -363,21 +363,21 @@ check_increments <- function(increments, covariates) { #' library(scda) #' library(dplyr) #' -#' ADTTE <- synthetic_cdisc_data("latest")$adtte -#' ADTTE_f <- subset(ADTTE, PARAMCD == "OS") # _f: filtered -#' ADTTE_f <- filter( -#' ADTTE_f, +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") +#' adtte_f <- subset(adtte, PARAMCD == "OS") # _f: filtered +#' adtte_f <- filter( +#' adtte_f, #' PARAMCD == "OS" & #' SEX %in% c("F", "M") & #' RACE %in% c("ASIAN", "BLACK OR AFRICAN AMERICAN", "WHITE") #' ) -#' ADTTE_f$SEX <- droplevels(ADTTE_f$SEX) -#' ADTTE_f$RACE <- droplevels(ADTTE_f$RACE) +#' adtte_f$SEX <- droplevels(adtte_f$SEX) +#' adtte_f$RACE <- droplevels(adtte_f$RACE) #' #' # Internal function - s_cox_multivariate #' \dontrun{ #' s_cox_multivariate( -#' formula = Surv(time = AVAL, event = 1 - CNSR) ~ (ARMCD + RACE + AGE)^2, data = ADTTE_f +#' formula = Surv(time = AVAL, event = 1 - CNSR) ~ (ARMCD + RACE + AGE)^2, data = adtte_f #' ) #' } #' diff --git a/R/fit_rsp_step.R b/R/fit_rsp_step.R index 8ce5d94ca1..be57c9807d 100644 --- a/R/fit_rsp_step.R +++ b/R/fit_rsp_step.R @@ -26,13 +26,12 @@ #' customization options. #' @export #' @examples -#' #' # Testing dataset with just two treatment arms. #' library(survival) #' library(dplyr) #' library(scda) #' -#' adrs <- synthetic_cdisc_data("latest")$adrs +#' adrs <- synthetic_cdisc_dataset("latest", "adrs") #' adrs_f <- adrs %>% #' filter( #' PARAMCD == "BESRSPI", diff --git a/R/fit_survival_step.R b/R/fit_survival_step.R index 669a2ed551..3468e41fe8 100644 --- a/R/fit_survival_step.R +++ b/R/fit_survival_step.R @@ -21,13 +21,12 @@ #' @seealso [control_step()] and [control_coxph()] for the available customization options. #' @export #' @examples -#' #' # Testing dataset with just two treatment arms. #' library(scda) #' library(dplyr) #' library(rtables) #' -#' adtte <- synthetic_cdisc_data("latest")$adtte +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") #' #' adtte_f <- adtte %>% #' filter( diff --git a/R/g_forest.R b/R/g_forest.R index f1388613ed..930b8a5085 100644 --- a/R/g_forest.R +++ b/R/g_forest.R @@ -43,7 +43,8 @@ #' library(forcats) #' library(rtables) #' library(nestcolor) -#' adrs <- synthetic_cdisc_data("latest")$adrs +#' +#' adrs <- synthetic_cdisc_dataset("latest", "adrs") #' n_records <- 20 #' adrs_labels <- formatters::var_labels(adrs, fill = TRUE) #' adrs <- adrs %>% @@ -82,7 +83,7 @@ #' draw_grob(p) #' #' # Survival forest plot example. -#' adtte <- synthetic_cdisc_data("latest")$adtte +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") #' # Save variable labels before data processing steps. #' adtte_labels <- formatters::var_labels(adtte, fill = TRUE) #' adtte_f <- adtte %>% diff --git a/R/g_lineplot.R b/R/g_lineplot.R index 58511ff22f..3938a5640b 100644 --- a/R/g_lineplot.R +++ b/R/g_lineplot.R @@ -79,11 +79,11 @@ #' @export #' #' @examples +#' library(scda) #' library(nestcolor) #' -#' cached_data <- scda::synthetic_cdisc_data("latest") -#' adsl <- cached_data$adsl -#' adlb <- cached_data$adlb +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") +#' adlb <- synthetic_cdisc_dataset("latest", "adlb") #' adlb <- dplyr::filter(adlb, ANL01FL == "Y", PARAMCD == "ALT", AVISIT != "SCREENING") #' adlb$AVISIT <- droplevels(adlb$AVISIT) #' adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) diff --git a/R/g_waterfall.R b/R/g_waterfall.R index d3495baee1..61351cab3b 100644 --- a/R/g_waterfall.R +++ b/R/g_waterfall.R @@ -40,11 +40,11 @@ #' library(scda) #' library(dplyr) #' -#' ADSL <- synthetic_cdisc_data("latest")$adsl +#' ADSL <- synthetic_cdisc_dataset("latest", "adsl") #' ADSL_f <- ADSL %>% #' select(USUBJID, STUDYID, ARM, ARMCD, SEX) #' -#' ADRS <- synthetic_cdisc_data("latest")$adrs +#' ADRS <- synthetic_cdisc_dataset("latest", "adrs") #' ADRS_f <- ADRS %>% #' filter(PARAMCD == "OVRINV") %>% #' mutate(pchg = rnorm(n(), 10, 50)) diff --git a/R/h_adsl_adlb_merge_using_worst_flag.R b/R/h_adsl_adlb_merge_using_worst_flag.R index ca897198a5..31a0cd4cc8 100644 --- a/R/h_adsl_adlb_merge_using_worst_flag.R +++ b/R/h_adsl_adlb_merge_using_worst_flag.R @@ -28,8 +28,8 @@ #' #' @examples #' library(scda) -#' adlb <- synthetic_cdisc_data("latest")$adlb -#' adsl <- synthetic_cdisc_data("latest")$adsl +#' adlb <- synthetic_cdisc_dataset("latest", "adlb") +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") #' #' # `h_adsl_adlb_merge_using_worst_flag` #' adlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl, adlb, worst_flag = c("WGRHIFL" = "Y")) diff --git a/R/h_map_for_count_abnormal.R b/R/h_map_for_count_abnormal.R index c6321e8554..cfd0ffe1b1 100644 --- a/R/h_map_for_count_abnormal.R +++ b/R/h_map_for_count_abnormal.R @@ -19,7 +19,7 @@ #' #' @examples #' library(scda) -#' adlb <- synthetic_cdisc_data("latest")$adlb +#' adlb <- synthetic_cdisc_dataset("latest", "adlb") #' adlb <- df_explicit_na(adlb) #' #' h_map_for_count_abnormal( diff --git a/R/h_pkparam_sort.R b/R/h_pkparam_sort.R index 22b72851c7..cdbe2aa6e9 100644 --- a/R/h_pkparam_sort.R +++ b/R/h_pkparam_sort.R @@ -11,7 +11,7 @@ #' library(scda) #' library(dplyr) #' -#' adpp <- synthetic_cdisc_data("latest")$adpp +#' adpp <- synthetic_cdisc_dataset("latest", "adpp") #' adpp <- adpp %>% mutate(PKPARAM = factor(paste0(PARAM, " (", AVALU, ")"))) #' #' pk_ordered_data <- h_pkparam_sort(adpp) diff --git a/R/h_response_biomarkers_subgroups.R b/R/h_response_biomarkers_subgroups.R index 1fae56db39..724e721b1e 100644 --- a/R/h_response_biomarkers_subgroups.R +++ b/R/h_response_biomarkers_subgroups.R @@ -16,7 +16,7 @@ #' library(forcats) #' library(rtables) #' -#' adrs <- synthetic_cdisc_data("latest")$adrs +#' adrs <- synthetic_cdisc_dataset("latest", "adrs") #' adrs_labels <- formatters::var_labels(adrs) #' #' adrs_f <- adrs %>% diff --git a/R/h_response_subgroups.R b/R/h_response_subgroups.R index 26f343d248..e243b778ae 100644 --- a/R/h_response_subgroups.R +++ b/R/h_response_subgroups.R @@ -19,7 +19,7 @@ #' library(forcats) #' library(rtables) #' -#' adrs <- synthetic_cdisc_data("latest")$adrs +#' adrs <- synthetic_cdisc_dataset("latest", "adrs") #' adrs_labels <- formatters::var_labels(adrs) #' #' adrs_f <- adrs %>% diff --git a/R/h_stack_by_baskets.R b/R/h_stack_by_baskets.R index 034a3726f5..3705122cb7 100644 --- a/R/h_stack_by_baskets.R +++ b/R/h_stack_by_baskets.R @@ -24,7 +24,7 @@ #' @examples #' library(scda) #' -#' adae <- synthetic_cdisc_data("latest")$adae[1:20, ] %>% df_explicit_na() +#' adae <- synthetic_cdisc_dataset("latest", "adae")[1:20, ] %>% df_explicit_na() #' h_stack_by_baskets(df = adae) #' #' aag <- data.frame( diff --git a/R/h_survival_biomarkers_subgroups.R b/R/h_survival_biomarkers_subgroups.R index 0d866fae9a..4211a69a6e 100644 --- a/R/h_survival_biomarkers_subgroups.R +++ b/R/h_survival_biomarkers_subgroups.R @@ -18,7 +18,7 @@ #' library(forcats) #' library(rtables) #' -#' adtte <- synthetic_cdisc_data("latest")$adtte +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") #' #' # Save variable labels before data processing steps. #' adtte_labels <- formatters::var_labels(adtte, fill = FALSE) diff --git a/R/h_survival_duration_subgroups.R b/R/h_survival_duration_subgroups.R index 94fbc3bf23..413b295514 100644 --- a/R/h_survival_duration_subgroups.R +++ b/R/h_survival_duration_subgroups.R @@ -21,7 +21,7 @@ #' library(forcats) #' library(rtables) #' -#' adtte <- synthetic_cdisc_data("latest")$adtte +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") #' #' # Save variable labels before data processing steps. #' adtte_labels <- formatters::var_labels(adtte) diff --git a/R/individual_patient_plot.R b/R/individual_patient_plot.R index bf956bf9f3..b3dbb4f4b5 100644 --- a/R/individual_patient_plot.R +++ b/R/individual_patient_plot.R @@ -36,13 +36,12 @@ NULL #' @inheritParams argument_convention #' @export #' @examples -#' #' library(scda) #' library(dplyr) #' library(nestcolor) #' #' # Select a small sample of data to plot. -#' adlb <- synthetic_cdisc_data("latest")$adlb %>% +#' adlb <- synthetic_cdisc_dataset("latest", "adlb") %>% #' filter(PARAMCD == "ALT", !(AVISIT %in% c("SCREENING", "BASELINE"))) %>% #' slice(1:36) #' diff --git a/R/kaplan_meier_plot.R b/R/kaplan_meier_plot.R index 60e243528e..d071780d0b 100644 --- a/R/kaplan_meier_plot.R +++ b/R/kaplan_meier_plot.R @@ -87,7 +87,7 @@ NULL #' library(grid) #' library(nestcolor) #' -#' df <- synthetic_cdisc_data("latest")$adtte %>% +#' df <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' mutate(is_event = CNSR == 0) #' variables <- list(tte = "AVAL", is_event = "is_event", arm = "ARMCD") @@ -394,7 +394,7 @@ g_km <- function(df, ) } - if (newpage & draw) grid::grid.newpage() + if (newpage && draw) grid::grid.newpage() if (draw) grid::grid.draw(result) invisible(result) } @@ -426,13 +426,13 @@ g_km <- function(df, #' library(survival) #' #' # Test with multiple arms -#' synthetic_cdisc_data("latest")$adtte %>% +#' synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% #' h_data_plot() #' #' # Test with single arm -#' synthetic_cdisc_data("latest")$adtte %>% +#' synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS", ARMCD == "ARM B") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% #' h_data_plot(armval = "ARM B") @@ -499,7 +499,7 @@ h_data_plot <- function(fit_km, #' library(dplyr) #' library(survival) #' -#' data <- synthetic_cdisc_data("latest")$adtte %>% +#' data <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% #' h_data_plot() @@ -553,7 +553,7 @@ h_xticks <- function(data, xticks = NULL, max_time = NULL) { #' library(dplyr) #' library(survival) #' -#' fit_km <- synthetic_cdisc_data("latest")$adtte %>% +#' fit_km <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) #' data_plot <- h_data_plot(fit_km = fit_km) @@ -704,7 +704,7 @@ h_ggkm <- function(data, #' library(survival) #' library(grid) #' -#' fit_km <- synthetic_cdisc_data("latest")$adtte %>% +#' fit_km <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) #' data_plot <- h_data_plot(fit_km = fit_km) @@ -773,7 +773,7 @@ h_decompose_gg <- function(gg) { #' library(dplyr) #' library(survival) #' -#' fit_km <- synthetic_cdisc_data("latest")$adtte %>% +#' fit_km <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) #' data_plot <- h_data_plot(fit_km = fit_km) @@ -876,7 +876,7 @@ h_km_layout <- function(data, g_el, title, footnotes, annot_at_risk = TRUE) { #' library(survival) #' library(grid) #' -#' fit_km <- synthetic_cdisc_data("latest")$adtte %>% +#' fit_km <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) #' @@ -1014,7 +1014,7 @@ h_grob_tbl_at_risk <- function(data, annot_tbl, xlim) { #' library(dplyr) #' library(survival) #' -#' adtte <- synthetic_cdisc_data("latest")$adtte %>% +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") #' #' fit <- survfit( @@ -1069,7 +1069,7 @@ h_tbl_median_surv <- function(fit_km, armval = "All") { #' #' grid::grid.newpage() #' grid.rect(gp = grid::gpar(lty = 1, col = "pink", fill = "gray85", lwd = 1)) -#' synthetic_cdisc_data("latest")$adtte %>% +#' synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>% #' h_grob_median_surv() %>% @@ -1118,7 +1118,7 @@ h_grob_median_surv <- function(fit_km, #' library(survival) #' library(grid) #' -#' fit_km <- synthetic_cdisc_data("latest")$adtte %>% +#' fit_km <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) #' data_plot <- h_data_plot(fit_km = fit_km) @@ -1165,7 +1165,7 @@ h_grob_y_annot <- function(ylab, yaxis) { #' library(scda) #' library(dplyr) #' -#' adtte <- synthetic_cdisc_data("latest")$adtte %>% +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' mutate(is_event = CNSR == 0) #' @@ -1231,7 +1231,7 @@ h_tbl_coxph_pairwise <- function(df, #' #' grid::grid.newpage() #' grid.rect(gp = grid::gpar(lty = 1, col = "pink", fill = "gray85", lwd = 1)) -#' data <- synthetic_cdisc_data("latest")$adtte %>% +#' data <- synthetic_cdisc_dataset("latest", "adtte") %>% #' filter(PARAMCD == "OS") %>% #' mutate(is_event = CNSR == 0) #' tbl_grob <- h_grob_coxph( diff --git a/R/logistic_regression.R b/R/logistic_regression.R index 7a06311ea4..88a4aaf42e 100644 --- a/R/logistic_regression.R +++ b/R/logistic_regression.R @@ -50,7 +50,7 @@ NULL #' library(dplyr) #' library(rtables) #' -#' adrs <- synthetic_cdisc_data("latest")$adrs +#' adrs <- synthetic_cdisc_dataset("latest", "adrs") #' adrs_f <- adrs %>% #' filter(PARAMCD == "BESRSPI") %>% #' filter(RACE %in% c("ASIAN", "WHITE", "BLACK OR AFRICAN AMERICAN")) %>% diff --git a/R/response_biomarkers_subgroups.R b/R/response_biomarkers_subgroups.R index 1516a0dc43..92a445f1d6 100644 --- a/R/response_biomarkers_subgroups.R +++ b/R/response_biomarkers_subgroups.R @@ -19,7 +19,7 @@ #' library(forcats) #' library(rtables) #' -#' adrs <- synthetic_cdisc_data("latest")$adrs +#' adrs <- synthetic_cdisc_dataset("latest", "adrs") #' adrs_labels <- formatters::var_labels(adrs) #' #' adrs_f <- adrs %>% diff --git a/R/response_subgroups.R b/R/response_subgroups.R index 4a393b4ce0..fdfaf63ff7 100644 --- a/R/response_subgroups.R +++ b/R/response_subgroups.R @@ -18,15 +18,15 @@ #' so no test is performed. #' @name response_subgroups #' @order 1 -#' @examples #' +#' @examples #' # Testing dataset. #' library(scda) #' library(dplyr) #' library(forcats) #' library(rtables) #' -#' adrs <- synthetic_cdisc_data("latest")$adrs +#' adrs <- synthetic_cdisc_dataset("latest", "adrs") #' adrs_labels <- formatters::var_labels(adrs) #' #' adrs_f <- adrs %>% diff --git a/R/score_occurrences.R b/R/score_occurrences.R index d1d1024f93..1f7f6acba1 100644 --- a/R/score_occurrences.R +++ b/R/score_occurrences.R @@ -15,11 +15,10 @@ NULL #' @export #' #' @examples -#' #' library(scda) #' library(rtables) -#' adsl <- synthetic_cdisc_data("latest")$adsl -#' adae <- synthetic_cdisc_data("latest")$adae +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") +#' adae <- synthetic_cdisc_dataset("latest", "adae") #' #' lyt <- basic_table() %>% #' split_cols_by("ARM") %>% diff --git a/R/summarize_ancova.R b/R/summarize_ancova.R index daa2033ab7..dd872efb3c 100644 --- a/R/summarize_ancova.R +++ b/R/summarize_ancova.R @@ -92,13 +92,12 @@ h_ancova <- function(.var, #' comparison to the reference group. #' - `pval`: p-value (not adjusted for multiple comparisons). #' -#' #' @examples #' library(scda) #' library(dplyr) #' -#' adsl <- synthetic_cdisc_data("rcd_2022_02_28")$adsl -#' adqs <- synthetic_cdisc_data("rcd_2022_02_28")$adqs +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") +#' adqs <- synthetic_cdisc_dataset("latest", "adqs") #' #' adqs_single <- adqs %>% #' filter( @@ -242,16 +241,15 @@ a_ancova <- make_afun( #' summary tables for analysis of covariance (ANCOVA). #' @inheritParams argument_convention #' @export -#' @examples #' +#' @examples #' library(scda) #' library(rtables) #' library(dplyr) #' -#' cached_data <- synthetic_cdisc_data("rcd_2022_02_28") +#' adsl <- synthetic_cdisc_dataset("latest", "adsl") +#' adqs <- synthetic_cdisc_dataset("latest", "adqs") #' -#' adsl <- cached_data$adsl -#' adqs <- cached_data$adqs #' adqs_single <- adqs %>% #' filter( #' AVISIT == "WEEK 1 DAY 8", # single time point @@ -281,8 +279,6 @@ a_ancova <- make_afun( #' #' # Another example: count the interaction between rows and columns into consideration #' -#' adsl <- cached_data$adsl -#' adqs <- cached_data$adqs #' adqs_single <- adqs %>% #' filter(AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 5 DAY 36")) %>% #' droplevels() %>% diff --git a/R/summarize_variables_in_cols.R b/R/summarize_variables_in_cols.R index cda587a5ad..be6c952180 100644 --- a/R/summarize_variables_in_cols.R +++ b/R/summarize_variables_in_cols.R @@ -19,12 +19,12 @@ NULL #' See [s_summary.numeric()] to be aware of all available statistics. #' #' @export -#' @examples #' +#' @examples #' library(scda) #' library(dplyr) -#' ADPP <- scda::synthetic_cdisc_data("latest")$adpp %>% h_pkparam_sort() -#' summary_in_cols(ADPP$AGE, custom_label = "stats") +#' adpp <- synthetic_cdisc_dataset("latest", "adpp") %>% h_pkparam_sort() +#' summary_in_cols(adpp$AGE, custom_label = "stats") summary_in_cols.numeric <- function(x, labelstr = "", custom_label = NULL, @@ -43,7 +43,6 @@ summary_in_cols.numeric <- function(x, lapply(results, formatters::with_label, row_label) } - #' @describeIn summarize_variables_in_columns a wrapper of #' [s_summary.factor()] function that produces a named list of statistics to include as columns. #' @@ -73,7 +72,6 @@ summary_in_cols.factor <- function(x, lapply(results, formatters::with_label, row_label) } - #' @describeIn summarize_variables_in_columns a wrapper of [s_summary.character()] #' function that produces a named list of statistics to include as columns. #' @@ -145,7 +143,6 @@ summary_in_cols <- function(x, UseMethod("summary_in_cols", x) } - #' @describeIn summarize_variables_in_columns Layout creating #' function which can be used for creating summary tables in columns, primarily used for PK data sets. #' @@ -157,12 +154,11 @@ summary_in_cols <- function(x, #' #' @export #' @examples -#' #' lyt <- basic_table() %>% #' split_rows_by(var = "ARM", label_pos = "topleft") %>% #' split_rows_by(var = "SEX", label_pos = "topleft") %>% #' summarize_vars_in_cols(var = "AGE", col_split = TRUE) -#' result <- build_table(lyt = lyt, df = ADPP) +#' result <- build_table(lyt = lyt, df = adpp) #' result #' #' # By selecting just some statistics and ad-hoc labels @@ -183,7 +179,7 @@ summary_in_cols <- function(x, #' ), #' col_split = TRUE #' ) -#' result <- build_table(lyt = lyt, df = ADPP) +#' result <- build_table(lyt = lyt, df = adpp) #' result #' #' lyt <- basic_table() %>% @@ -192,7 +188,7 @@ summary_in_cols <- function(x, #' col_split = TRUE, #' custom_label = "some custom label" #' ) -#' result <- build_table(lyt, df = ADPP) +#' result <- build_table(lyt, df = adpp) #' result #' #' # PKPT03 @@ -214,7 +210,7 @@ summary_in_cols <- function(x, #' max = "Maximum" #' ) #' ) -#' result <- build_table(lyt, df = ADPP) +#' result <- build_table(lyt, df = adpp) #' result summarize_vars_in_cols <- function(lyt, var, diff --git a/R/survival_biomarkers_subgroups.R b/R/survival_biomarkers_subgroups.R index 6c7172af83..1986573fd4 100644 --- a/R/survival_biomarkers_subgroups.R +++ b/R/survival_biomarkers_subgroups.R @@ -20,7 +20,7 @@ #' library(forcats) #' library(rtables) #' -#' adtte <- synthetic_cdisc_data("latest")$adtte +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") #' #' # Save variable labels before data processing steps. #' adtte_labels <- formatters::var_labels(adtte) diff --git a/R/survival_coxph_pairwise.R b/R/survival_coxph_pairwise.R index 592c5e6101..1f84e78707 100644 --- a/R/survival_coxph_pairwise.R +++ b/R/survival_coxph_pairwise.R @@ -11,7 +11,8 @@ #' @param control (`list`) \cr parameters for comparison details, specified by using \cr #' the helper function [control_coxph()]. Some possible parameter options are: \cr #' * `pval_method`: (`string`) \cr p-value method for testing hazard ratio = 1. -#' Default method is "log-rank" which comes from [survival::survdiff()], can also be set to "wald" or "likelihood" that comes from [survival::coxph()]. +#' Default method is "log-rank" which comes from [survival::survdiff()], can also be set to "wald" or "likelihood" +#' that comes from [survival::coxph()]. #' * `ties`: (`string`) \cr specifying the method for tie handling. Default is "efron", #' can also be set to "breslow" or "exact". See more in [survival::coxph()] #' * `conf_level`: (`proportion`)\cr confidence level of the interval for HR. @@ -34,13 +35,13 @@ NULL #' library(scda) #' library(dplyr) #' -#' ADTTE <- synthetic_cdisc_data("latest")$adtte -#' ADTTE_f <- ADTTE %>% +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") +#' adtte_f <- adtte %>% #' filter(PARAMCD == "OS") %>% #' mutate(is_event = CNSR == 0) -#' df <- ADTTE_f %>% +#' df <- adtte_f %>% #' filter(ARMCD == "ARM A") -#' df_ref_group <- ADTTE_f %>% +#' df_ref_group <- adtte_f %>% #' filter(ARMCD == "ARM B") #' #' # Internal function - s_coxph_pairwise @@ -157,7 +158,7 @@ a_coxph_pairwise <- make_afun( #' is_event = "is_event", #' var_labels = "Unstratified Analysis" #' ) %>% -#' build_table(df = ADTTE_f) +#' build_table(df = adtte_f) #' #' basic_table() %>% #' split_cols_by(var = "ARMCD", ref_group = "ARM A") %>% @@ -169,7 +170,7 @@ a_coxph_pairwise <- make_afun( #' strat = "SEX", #' control = control_coxph(pval_method = "wald") #' ) %>% -#' build_table(df = ADTTE_f) +#' build_table(df = adtte_f) coxph_pairwise <- function(lyt, vars, ..., diff --git a/R/survival_duration_subgroups.R b/R/survival_duration_subgroups.R index 817675af42..83adae7a51 100644 --- a/R/survival_duration_subgroups.R +++ b/R/survival_duration_subgroups.R @@ -18,15 +18,15 @@ #' displaying unit. #' @name survival_duration_subgroups #' @order 1 -#' @examples #' +#' @examples #' # Testing dataset. #' library(scda) #' library(dplyr) #' library(forcats) #' library(rtables) #' -#' adtte <- synthetic_cdisc_data("latest")$adtte +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") #' #' # Save variable labels before data processing steps. #' adtte_labels <- formatters::var_labels(adtte) diff --git a/R/survival_time.R b/R/survival_time.R index 6f37ad8919..be8aad04cf 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -28,18 +28,19 @@ NULL #' * `range_censor` : survival time range for censored observations. #' * `range_event` : survival time range for observations with events. #' * `range` : survival time range for all observations. +#' #' @examples #' library(scda) #' library(dplyr) #' -#' ADTTE <- synthetic_cdisc_data("latest")$adtte -#' ADTTE_f <- ADTTE %>% +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") +#' adtte_f <- adtte %>% #' filter(PARAMCD == "OS") %>% #' mutate( #' AVAL = day2month(AVAL), #' is_event = CNSR == 0 #' ) -#' df <- ADTTE_f %>% filter(ARMCD == "ARM A") +#' df <- adtte_f %>% filter(ARMCD == "ARM A") #' #' # Internal function - s_surv_time #' \dontrun{ @@ -130,7 +131,7 @@ a_surv_time <- make_afun( #' is_event = "is_event", #' control = control_surv_time(conf_level = 0.9, conf_type = "log-log") #' ) %>% -#' build_table(df = ADTTE_f) +#' build_table(df = adtte_f) surv_time <- function(lyt, vars, ..., diff --git a/R/survival_timepoint.R b/R/survival_timepoint.R index e86b0f9fd2..a7ad54c828 100644 --- a/R/survival_timepoint.R +++ b/R/survival_timepoint.R @@ -25,18 +25,19 @@ NULL #' * `event_free_rate` : event free rate (%). #' * `rate_se` : standard error of event free rate. #' * `rate_ci` : confidence interval for event free rate. +#' #' @examples #' library(scda) #' library(dplyr) #' -#' ADTTE <- synthetic_cdisc_data("latest")$adtte -#' ADTTE_f <- ADTTE %>% +#' adtte <- synthetic_cdisc_dataset("latest", "adtte") +#' adtte_f <- adtte %>% #' filter(PARAMCD == "OS") %>% #' mutate( #' AVAL = day2month(AVAL), #' is_event = CNSR == 0 #' ) -#' df <- ADTTE_f %>% +#' df <- adtte_f %>% #' filter(ARMCD == "ARM A") #' #' # Internal function - s_surv_timepoint @@ -118,7 +119,7 @@ a_surv_timepoint <- make_afun( #' * `ztest_pval` : p-value to test the difference is 0. #' #' @examples -#' df_ref_group <- ADTTE_f %>% +#' df_ref_group <- adtte_f %>% #' filter(ARMCD == "ARM B") #' #' # Internal function - s_surv_timepoint_diff @@ -227,7 +228,7 @@ a_surv_timepoint_diff <- make_afun( #' is_event = "is_event", #' time_point = 7 #' ) %>% -#' build_table(df = ADTTE_f) +#' build_table(df = adtte_f) #' #' # Difference in survival at given time points. #' basic_table() %>% @@ -241,7 +242,7 @@ a_surv_timepoint_diff <- make_afun( #' method = "surv_diff", #' .indent_mods = c("rate_diff" = 0L, "rate_diff_ci" = 2L, "ztest_pval" = 2L) #' ) %>% -#' build_table(df = ADTTE_f) +#' build_table(df = adtte_f) #' #' # Survival and difference in survival at given time points. #' basic_table() %>% @@ -254,7 +255,7 @@ a_surv_timepoint_diff <- make_afun( #' time_point = 9, #' method = "both" #' ) %>% -#' build_table(df = ADTTE_f) +#' build_table(df = adtte_f) surv_timepoint <- function(lyt, vars, ..., diff --git a/R/utils.R b/R/utils.R index c190e4d353..d0a252dbe1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -291,7 +291,7 @@ extract_by_name <- function(x, names) { #' #' @examples #' library(scda) -#' adae <- synthetic_cdisc_data("latest")$adae +#' adae <- synthetic_cdisc_dataset("latest", "adae") #' #' # Standardized query label includes scope. #' aesi_label(adae$SMQ01NAM, scope = adae$SMQ01SC) @@ -306,12 +306,12 @@ aesi_label <- function(aesi, scope = NULL) { aesi <- sas_na(aesi) aesi <- unique(aesi)[!is.na(unique(aesi))] - lbl <- if (length(aesi) == 1 & !is.null(scope)) { + lbl <- if (length(aesi) == 1 && !is.null(scope)) { scope <- sas_na(scope) scope <- unique(scope)[!is.na(unique(scope))] checkmate::assert_string(scope) paste0(aesi, " (", scope, ")") - } else if (length(aesi) == 1 & is.null(scope)) { + } else if (length(aesi) == 1 && is.null(scope)) { aesi } else { aesi_label diff --git a/man/abnormal_by_worst_grade.Rd b/man/abnormal_by_worst_grade.Rd index ae8ea0adb7..a6a81d6ffa 100644 --- a/man/abnormal_by_worst_grade.Rd +++ b/man/abnormal_by_worst_grade.Rd @@ -102,8 +102,7 @@ which can take statistics function arguments and additional format arguments (se library(scda) library(dplyr) library(forcats) - -adlb <- synthetic_cdisc_data("latest")$adlb +adlb <- synthetic_cdisc_dataset("latest", "adlb") # Data is modified in order to have some parameters with grades only in one direction # and simulate the real data. diff --git a/man/abnormal_by_worst_grade_worsen.Rd b/man/abnormal_by_worst_grade_worsen.Rd index 82ce4fbbfd..31483a5c5e 100644 --- a/man/abnormal_by_worst_grade_worsen.Rd +++ b/man/abnormal_by_worst_grade_worsen.Rd @@ -138,11 +138,10 @@ function arguments and additional format arguments (see below). }} \examples{ - library(scda) library(dplyr) -adlb <- synthetic_cdisc_data("latest")$adlb -adsl <- synthetic_cdisc_data("latest")$adsl +adsl <- synthetic_cdisc_dataset("latest", "adsl") +adlb <- synthetic_cdisc_dataset("latest", "adlb") # The direction variable, GRADDR, is based on metadata adlb <- adlb \%>\% diff --git a/man/aesi_label.Rd b/man/aesi_label.Rd index 56a335e589..b9c335174f 100644 --- a/man/aesi_label.Rd +++ b/man/aesi_label.Rd @@ -20,7 +20,7 @@ A \code{string} with the standard label for the AE basket. } \examples{ library(scda) -adae <- synthetic_cdisc_data("latest")$adae +adae <- synthetic_cdisc_dataset("latest", "adae") # Standardized query label includes scope. aesi_label(adae$SMQ01NAM, scope = adae$SMQ01SC) diff --git a/man/count_cumulative.Rd b/man/count_cumulative.Rd index 139758bf22..f5f4307183 100644 --- a/man/count_cumulative.Rd +++ b/man/count_cumulative.Rd @@ -145,7 +145,8 @@ afun(x, thresholds = c(0, 5, 11), .N_col = .N_col) } library(scda) -ADSL <- synthetic_cdisc_data("latest")$adsl +ADSL <- synthetic_cdisc_dataset("latest", "adsl") + basic_table() \%>\% split_cols_by("ARM") \%>\% add_colcounts() \%>\% @@ -154,5 +155,6 @@ basic_table() \%>\% thresholds = c(40, 60) ) \%>\% build_table(ADSL) + } \keyword{internal} diff --git a/man/count_missed_doses.Rd b/man/count_missed_doses.Rd index d3dabe387d..c6bcbbd207 100644 --- a/man/count_missed_doses.Rd +++ b/man/count_missed_doses.Rd @@ -112,8 +112,9 @@ afun(x = c(0, 1, 0, 2, 3, 4, 0, 2), thresholds = c(2, 5), .N_col = 10) library(dplyr) library(scda) -adex <- synthetic_cdisc_data("latest")$adex -adsl <- synthetic_cdisc_data("latest")$adsl +adex <- synthetic_cdisc_dataset("latest", "adex") +adsl <- synthetic_cdisc_dataset("latest", "adsl") + anl <- adex \%>\% distinct(STUDYID, USUBJID, ARM) \%>\% mutate( diff --git a/man/count_patients_with_event.Rd b/man/count_patients_with_event.Rd index fd6baa60c0..a28f1f70bb 100644 --- a/man/count_patients_with_event.Rd +++ b/man/count_patients_with_event.Rd @@ -151,12 +151,10 @@ Adds the count statistics to the input layout for multiple flag variables at onc }} \examples{ - - library(dplyr) library(scda) -adae <- synthetic_cdisc_data("latest")$adae -adsl <- synthetic_cdisc_data("latest")$adsl +adae <- synthetic_cdisc_dataset("latest", "adae") +adsl <- synthetic_cdisc_dataset("latest", "adsl") # `s_count_patients_with_event()` diff --git a/man/estimate_coef.Rd b/man/estimate_coef.Rd index 7e76be4829..a598df4641 100644 --- a/man/estimate_coef.Rd +++ b/man/estimate_coef.Rd @@ -63,18 +63,18 @@ library(dplyr) library(scda) library(survival) -ADSL <- synthetic_cdisc_data("latest")$adsl +ADSL <- synthetic_cdisc_dataset("latest", "adsl") ADSL <- ADSL \%>\% filter(SEX \%in\% c("F", "M")) -ADTTE <- synthetic_cdisc_data("latest")$adtte \%>\% +adtte <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "PFS") -ADTTE$ARMCD <- droplevels(ADTTE$ARMCD) -ADTTE$SEX <- droplevels(ADTTE$SEX) +adtte$ARMCD <- droplevels(adtte$ARMCD) +adtte$SEX <- droplevels(adtte$SEX) mod <- coxph( formula = Surv(time = AVAL, event = 1 - CNSR) ~ (SEX + ARMCD)^2, - data = ADTTE + data = adtte ) mmat <- stats::model.matrix(mod)[1, ] diff --git a/man/fit_rsp_step.Rd b/man/fit_rsp_step.Rd index 8da472b616..5d7795c6cf 100644 --- a/man/fit_rsp_step.Rd +++ b/man/fit_rsp_step.Rd @@ -36,13 +36,12 @@ where \code{degree} is specified by \code{control_step()}. Note that for the default degree 0 the \code{biomarker} variable is not included in the model. } \examples{ - # Testing dataset with just two treatment arms. library(survival) library(dplyr) library(scda) -adrs <- synthetic_cdisc_data("latest")$adrs +adrs <- synthetic_cdisc_dataset("latest", "adrs") adrs_f <- adrs \%>\% filter( PARAMCD == "BESRSPI", diff --git a/man/fit_survival_step.Rd b/man/fit_survival_step.Rd index 7fee6c53be..f46940af53 100644 --- a/man/fit_survival_step.Rd +++ b/man/fit_survival_step.Rd @@ -36,13 +36,12 @@ where \code{degree} is specified by \code{control_step()}. Note that for the default degree 0 the \code{biomarker} variable is not included in the model. } \examples{ - # Testing dataset with just two treatment arms. library(scda) library(dplyr) library(rtables) -adtte <- synthetic_cdisc_data("latest")$adtte +adtte <- synthetic_cdisc_dataset("latest", "adtte") adtte_f <- adtte \%>\% filter( diff --git a/man/g_forest.Rd b/man/g_forest.Rd index 8eed8ddddb..6f27dcf9e9 100644 --- a/man/g_forest.Rd +++ b/man/g_forest.Rd @@ -85,7 +85,8 @@ library(dplyr) library(forcats) library(rtables) library(nestcolor) -adrs <- synthetic_cdisc_data("latest")$adrs + +adrs <- synthetic_cdisc_dataset("latest", "adrs") n_records <- 20 adrs_labels <- formatters::var_labels(adrs, fill = TRUE) adrs <- adrs \%>\% @@ -124,7 +125,7 @@ p <- g_forest( draw_grob(p) # Survival forest plot example. -adtte <- synthetic_cdisc_data("latest")$adtte +adtte <- synthetic_cdisc_dataset("latest", "adtte") # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte, fill = TRUE) adtte_f <- adtte \%>\% diff --git a/man/g_km.Rd b/man/g_km.Rd index 9efbdd5060..a4a6d96bee 100644 --- a/man/g_km.Rd +++ b/man/g_km.Rd @@ -156,7 +156,7 @@ library(survival) library(grid) library(nestcolor) -df <- synthetic_cdisc_data("latest")$adtte \%>\% +df <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% mutate(is_event = CNSR == 0) variables <- list(tte = "AVAL", is_event = "is_event", arm = "ARMCD") diff --git a/man/g_lineplot.Rd b/man/g_lineplot.Rd index 1046bc1496..03ca73845e 100644 --- a/man/g_lineplot.Rd +++ b/man/g_lineplot.Rd @@ -142,11 +142,11 @@ controls the font size of values in the table.} Line plot with the optional table } \examples{ +library(scda) library(nestcolor) -cached_data <- scda::synthetic_cdisc_data("latest") -adsl <- cached_data$adsl -adlb <- cached_data$adlb +adsl <- synthetic_cdisc_dataset("latest", "adsl") +adlb <- synthetic_cdisc_dataset("latest", "adlb") adlb <- dplyr::filter(adlb, ANL01FL == "Y", PARAMCD == "ALT", AVISIT != "SCREENING") adlb$AVISIT <- droplevels(adlb$AVISIT) adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) diff --git a/man/g_waterfall.Rd b/man/g_waterfall.Rd index 79b2ae2e62..12dfb0cc8c 100644 --- a/man/g_waterfall.Rd +++ b/man/g_waterfall.Rd @@ -64,11 +64,11 @@ g_waterfall( library(scda) library(dplyr) -ADSL <- synthetic_cdisc_data("latest")$adsl +ADSL <- synthetic_cdisc_dataset("latest", "adsl") ADSL_f <- ADSL \%>\% select(USUBJID, STUDYID, ARM, ARMCD, SEX) -ADRS <- synthetic_cdisc_data("latest")$adrs +ADRS <- synthetic_cdisc_dataset("latest", "adrs") ADRS_f <- ADRS \%>\% filter(PARAMCD == "OVRINV") \%>\% mutate(pchg = rnorm(n(), 10, 50)) diff --git a/man/h_adsl_adlb_merge_using_worst_flag.Rd b/man/h_adsl_adlb_merge_using_worst_flag.Rd index 23f510f6d2..febd439c47 100644 --- a/man/h_adsl_adlb_merge_using_worst_flag.Rd +++ b/man/h_adsl_adlb_merge_using_worst_flag.Rd @@ -48,8 +48,8 @@ In the result data missing records will be created for the following situations: } \examples{ library(scda) -adlb <- synthetic_cdisc_data("latest")$adlb -adsl <- synthetic_cdisc_data("latest")$adsl +adlb <- synthetic_cdisc_dataset("latest", "adlb") +adsl <- synthetic_cdisc_dataset("latest", "adsl") # `h_adsl_adlb_merge_using_worst_flag` adlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl, adlb, worst_flag = c("WGRHIFL" = "Y")) diff --git a/man/h_data_plot.Rd b/man/h_data_plot.Rd index d0e0b3a89b..5d3224f1bd 100644 --- a/man/h_data_plot.Rd +++ b/man/h_data_plot.Rd @@ -40,13 +40,13 @@ library(dplyr) library(survival) # Test with multiple arms -synthetic_cdisc_data("latest")$adtte \%>\% +synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\% h_data_plot() # Test with single arm -synthetic_cdisc_data("latest")$adtte \%>\% +synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS", ARMCD == "ARM B") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\% h_data_plot(armval = "ARM B") diff --git a/man/h_decompose_gg.Rd b/man/h_decompose_gg.Rd index ff793e698e..72d8a8252a 100644 --- a/man/h_decompose_gg.Rd +++ b/man/h_decompose_gg.Rd @@ -25,7 +25,7 @@ library(dplyr) library(survival) library(grid) -fit_km <- synthetic_cdisc_data("latest")$adtte \%>\% +fit_km <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) diff --git a/man/h_ggkm.Rd b/man/h_ggkm.Rd index 49e0d20fe6..fc24616322 100644 --- a/man/h_ggkm.Rd +++ b/man/h_ggkm.Rd @@ -79,7 +79,7 @@ library(scda) library(dplyr) library(survival) -fit_km <- synthetic_cdisc_data("latest")$adtte \%>\% +fit_km <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) diff --git a/man/h_grob_coxph.Rd b/man/h_grob_coxph.Rd index ad62a38151..f8a9f8a8cb 100644 --- a/man/h_grob_coxph.Rd +++ b/man/h_grob_coxph.Rd @@ -35,7 +35,7 @@ library(grid) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = "pink", fill = "gray85", lwd = 1)) -data <- synthetic_cdisc_data("latest")$adtte \%>\% +data <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% mutate(is_event = CNSR == 0) tbl_grob <- h_grob_coxph( diff --git a/man/h_grob_median_surv.Rd b/man/h_grob_median_surv.Rd index 16d715e792..936e2a3538 100644 --- a/man/h_grob_median_surv.Rd +++ b/man/h_grob_median_surv.Rd @@ -39,7 +39,7 @@ library(grid) grid::grid.newpage() grid.rect(gp = grid::gpar(lty = 1, col = "pink", fill = "gray85", lwd = 1)) -synthetic_cdisc_data("latest")$adtte \%>\% +synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\% h_grob_median_surv() \%>\% diff --git a/man/h_grob_tbl_at_risk.Rd b/man/h_grob_tbl_at_risk.Rd index 0664657d9d..e404d56023 100644 --- a/man/h_grob_tbl_at_risk.Rd +++ b/man/h_grob_tbl_at_risk.Rd @@ -29,7 +29,7 @@ library(dplyr) library(survival) library(grid) -fit_km <- synthetic_cdisc_data("latest")$adtte \%>\% +fit_km <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) diff --git a/man/h_grob_y_annot.Rd b/man/h_grob_y_annot.Rd index c18fe883df..d1cc8f84bc 100644 --- a/man/h_grob_y_annot.Rd +++ b/man/h_grob_y_annot.Rd @@ -25,7 +25,7 @@ library(dplyr) library(survival) library(grid) -fit_km <- synthetic_cdisc_data("latest")$adtte \%>\% +fit_km <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) diff --git a/man/h_km_layout.Rd b/man/h_km_layout.Rd index b22c5c7e29..65a71d4a5b 100644 --- a/man/h_km_layout.Rd +++ b/man/h_km_layout.Rd @@ -43,7 +43,7 @@ library(scda) library(dplyr) library(survival) -fit_km <- synthetic_cdisc_data("latest")$adtte \%>\% +fit_km <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) data_plot <- h_data_plot(fit_km = fit_km) diff --git a/man/h_map_for_count_abnormal.Rd b/man/h_map_for_count_abnormal.Rd index 68f7de6158..e4554ff9c5 100644 --- a/man/h_map_for_count_abnormal.Rd +++ b/man/h_map_for_count_abnormal.Rd @@ -39,7 +39,7 @@ Helper Function to create a map dataframe from the input dataset, which can be u } \examples{ library(scda) -adlb <- synthetic_cdisc_data("latest")$adlb +adlb <- synthetic_cdisc_dataset("latest", "adlb") adlb <- df_explicit_na(adlb) h_map_for_count_abnormal( diff --git a/man/h_pkparam_sort.Rd b/man/h_pkparam_sort.Rd index 1bffc97e0f..f245c0527e 100644 --- a/man/h_pkparam_sort.Rd +++ b/man/h_pkparam_sort.Rd @@ -21,7 +21,7 @@ dataframe with \verb{PK PARAM} variable ordered library(scda) library(dplyr) -adpp <- synthetic_cdisc_data("latest")$adpp +adpp <- synthetic_cdisc_dataset("latest", "adpp") adpp <- adpp \%>\% mutate(PKPARAM = factor(paste0(PARAM, " (", AVALU, ")"))) pk_ordered_data <- h_pkparam_sort(adpp) diff --git a/man/h_response_biomarkers_subgroups.Rd b/man/h_response_biomarkers_subgroups.Rd index 9e06b639f5..436d24a148 100644 --- a/man/h_response_biomarkers_subgroups.Rd +++ b/man/h_response_biomarkers_subgroups.Rd @@ -67,7 +67,7 @@ library(dplyr) library(forcats) library(rtables) -adrs <- synthetic_cdisc_data("latest")$adrs +adrs <- synthetic_cdisc_dataset("latest", "adrs") adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs \%>\% diff --git a/man/h_response_subgroups.Rd b/man/h_response_subgroups.Rd index 776550a456..d9a24fd419 100644 --- a/man/h_response_subgroups.Rd +++ b/man/h_response_subgroups.Rd @@ -88,7 +88,7 @@ library(dplyr) library(forcats) library(rtables) -adrs <- synthetic_cdisc_data("latest")$adrs +adrs <- synthetic_cdisc_dataset("latest", "adrs") adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs \%>\% diff --git a/man/h_stack_by_baskets.Rd b/man/h_stack_by_baskets.Rd index 8460ff78be..6285ae9ede 100644 --- a/man/h_stack_by_baskets.Rd +++ b/man/h_stack_by_baskets.Rd @@ -43,7 +43,7 @@ belonging to any of the selected baskets. \examples{ library(scda) -adae <- synthetic_cdisc_data("latest")$adae[1:20, ] \%>\% df_explicit_na() +adae <- synthetic_cdisc_dataset("latest", "adae")[1:20, ] \%>\% df_explicit_na() h_stack_by_baskets(df = adae) aag <- data.frame( diff --git a/man/h_survival_biomarkers_subgroups.Rd b/man/h_survival_biomarkers_subgroups.Rd index 7acf5a7994..cbcb2e0d69 100644 --- a/man/h_survival_biomarkers_subgroups.Rd +++ b/man/h_survival_biomarkers_subgroups.Rd @@ -70,7 +70,7 @@ library(dplyr) library(forcats) library(rtables) -adtte <- synthetic_cdisc_data("latest")$adtte +adtte <- synthetic_cdisc_dataset("latest", "adtte") # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte, fill = FALSE) diff --git a/man/h_survival_duration_subgroups.Rd b/man/h_survival_duration_subgroups.Rd index fd44b5cad6..f7e5fa07db 100644 --- a/man/h_survival_duration_subgroups.Rd +++ b/man/h_survival_duration_subgroups.Rd @@ -51,7 +51,8 @@ required if stratified analysis is performed.} the helper function \code{\link[=control_coxph]{control_coxph()}}. Some possible parameter options are: \cr \itemize{ \item \code{pval_method}: (\code{string}) \cr p-value method for testing hazard ratio = 1. -Default method is "log-rank" which comes from \code{\link[survival:survdiff]{survival::survdiff()}}, can also be set to "wald" or "likelihood" that comes from \code{\link[survival:coxph]{survival::coxph()}}. +Default method is "log-rank" which comes from \code{\link[survival:survdiff]{survival::survdiff()}}, can also be set to "wald" or "likelihood" +that comes from \code{\link[survival:coxph]{survival::coxph()}}. \item \code{ties}: (\code{string}) \cr specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in \code{\link[survival:coxph]{survival::coxph()}} \item \code{conf_level}: (\code{proportion})\cr confidence level of the interval for HR. @@ -92,7 +93,7 @@ library(dplyr) library(forcats) library(rtables) -adtte <- synthetic_cdisc_data("latest")$adtte +adtte <- synthetic_cdisc_dataset("latest", "adtte") # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) diff --git a/man/h_tbl_coxph_pairwise.Rd b/man/h_tbl_coxph_pairwise.Rd index b20f30c50d..bd3c7a8ba8 100644 --- a/man/h_tbl_coxph_pairwise.Rd +++ b/man/h_tbl_coxph_pairwise.Rd @@ -38,7 +38,7 @@ Create an \code{rtable} of pairwise stratified or unstratified CoxPH analysis re library(scda) library(dplyr) -adtte <- synthetic_cdisc_data("latest")$adtte \%>\% +adtte <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% mutate(is_event = CNSR == 0) diff --git a/man/h_tbl_median_surv.Rd b/man/h_tbl_median_surv.Rd index 667ab7f702..53fe713e6d 100644 --- a/man/h_tbl_median_surv.Rd +++ b/man/h_tbl_median_surv.Rd @@ -24,7 +24,7 @@ library(scda) library(dplyr) library(survival) -adtte <- synthetic_cdisc_data("latest")$adtte \%>\% +adtte <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") fit <- survfit( diff --git a/man/h_xticks.Rd b/man/h_xticks.Rd index f920f6e905..a968cf26bb 100644 --- a/man/h_xticks.Rd +++ b/man/h_xticks.Rd @@ -32,7 +32,7 @@ library(scda) library(dplyr) library(survival) -data <- synthetic_cdisc_data("latest")$adtte \%>\% +data <- synthetic_cdisc_dataset("latest", "adtte") \%>\% filter(PARAMCD == "OS") \%>\% survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) \%>\% h_data_plot() diff --git a/man/individual_patient_plot.Rd b/man/individual_patient_plot.Rd index e30e21ba3e..b150c574d1 100644 --- a/man/individual_patient_plot.Rd +++ b/man/individual_patient_plot.Rd @@ -97,13 +97,12 @@ values over time. }} \examples{ - library(scda) library(dplyr) library(nestcolor) # Select a small sample of data to plot. -adlb <- synthetic_cdisc_data("latest")$adlb \%>\% +adlb <- synthetic_cdisc_dataset("latest", "adlb") \%>\% filter(PARAMCD == "ALT", !(AVISIT \%in\% c("SCREENING", "BASELINE"))) \%>\% slice(1:36) diff --git a/man/logistic_regression.Rd b/man/logistic_regression.Rd index 7292d79f26..b2c4a99885 100644 --- a/man/logistic_regression.Rd +++ b/man/logistic_regression.Rd @@ -232,7 +232,7 @@ library(scda) library(dplyr) library(rtables) -adrs <- synthetic_cdisc_data("latest")$adrs +adrs <- synthetic_cdisc_dataset("latest", "adrs") adrs_f <- adrs \%>\% filter(PARAMCD == "BESRSPI") \%>\% filter(RACE \%in\% c("ASIAN", "WHITE", "BLACK OR AFRICAN AMERICAN")) \%>\% diff --git a/man/response_biomarkers_subgroups.Rd b/man/response_biomarkers_subgroups.Rd index 32d11a3cb5..58b6a2de9a 100644 --- a/man/response_biomarkers_subgroups.Rd +++ b/man/response_biomarkers_subgroups.Rd @@ -84,7 +84,7 @@ library(dplyr) library(forcats) library(rtables) -adrs <- synthetic_cdisc_data("latest")$adrs +adrs <- synthetic_cdisc_dataset("latest", "adrs") adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs \%>\% diff --git a/man/response_subgroups.Rd b/man/response_subgroups.Rd index 2dbdd08ab2..8122ff0b46 100644 --- a/man/response_subgroups.Rd +++ b/man/response_subgroups.Rd @@ -84,14 +84,13 @@ Returns is a list of Formatted Analysis functions with one element per statistic }} \examples{ - # Testing dataset. library(scda) library(dplyr) library(forcats) library(rtables) -adrs <- synthetic_cdisc_data("latest")$adrs +adrs <- synthetic_cdisc_dataset("latest", "adrs") adrs_labels <- formatters::var_labels(adrs) adrs_f <- adrs \%>\% diff --git a/man/s_cox_multivariate.Rd b/man/s_cox_multivariate.Rd index 9b5262ea44..4781a18a56 100644 --- a/man/s_cox_multivariate.Rd +++ b/man/s_cox_multivariate.Rd @@ -47,21 +47,21 @@ but is out of scope as defined by the Global Data Standards Repository library(scda) library(dplyr) -ADTTE <- synthetic_cdisc_data("latest")$adtte -ADTTE_f <- subset(ADTTE, PARAMCD == "OS") # _f: filtered -ADTTE_f <- filter( - ADTTE_f, +adtte <- synthetic_cdisc_dataset("latest", "adtte") +adtte_f <- subset(adtte, PARAMCD == "OS") # _f: filtered +adtte_f <- filter( + adtte_f, PARAMCD == "OS" & SEX \%in\% c("F", "M") & RACE \%in\% c("ASIAN", "BLACK OR AFRICAN AMERICAN", "WHITE") ) -ADTTE_f$SEX <- droplevels(ADTTE_f$SEX) -ADTTE_f$RACE <- droplevels(ADTTE_f$RACE) +adtte_f$SEX <- droplevels(adtte_f$SEX) +adtte_f$RACE <- droplevels(adtte_f$RACE) # Internal function - s_cox_multivariate \dontrun{ s_cox_multivariate( - formula = Surv(time = AVAL, event = 1 - CNSR) ~ (ARMCD + RACE + AGE)^2, data = ADTTE_f + formula = Surv(time = AVAL, event = 1 - CNSR) ~ (ARMCD + RACE + AGE)^2, data = adtte_f ) } diff --git a/man/score_occurrences.Rd b/man/score_occurrences.Rd index 06c892000f..0f286d036a 100644 --- a/man/score_occurrences.Rd +++ b/man/score_occurrences.Rd @@ -53,11 +53,10 @@ specified columns. Note that this is extending \code{\link[rtables:score_funs]{r }} \examples{ - library(scda) library(rtables) -adsl <- synthetic_cdisc_data("latest")$adsl -adae <- synthetic_cdisc_data("latest")$adae +adsl <- synthetic_cdisc_dataset("latest", "adsl") +adae <- synthetic_cdisc_dataset("latest", "adae") lyt <- basic_table() \%>\% split_cols_by("ARM") \%>\% diff --git a/man/summarize_ancova.Rd b/man/summarize_ancova.Rd index bdb9225de0..79c7628211 100644 --- a/man/summarize_ancova.Rd +++ b/man/summarize_ancova.Rd @@ -143,8 +143,8 @@ h_ancova( library(scda) library(dplyr) -adsl <- synthetic_cdisc_data("rcd_2022_02_28")$adsl -adqs <- synthetic_cdisc_data("rcd_2022_02_28")$adqs +adsl <- synthetic_cdisc_dataset("latest", "adsl") +adqs <- synthetic_cdisc_dataset("latest", "adqs") adqs_single <- adqs \%>\% filter( @@ -180,15 +180,13 @@ a_ancova( ) } - library(scda) library(rtables) library(dplyr) -cached_data <- synthetic_cdisc_data("rcd_2022_02_28") +adsl <- synthetic_cdisc_dataset("latest", "adsl") +adqs <- synthetic_cdisc_dataset("latest", "adqs") -adsl <- cached_data$adsl -adqs <- cached_data$adqs adqs_single <- adqs \%>\% filter( AVISIT == "WEEK 1 DAY 8", # single time point @@ -218,8 +216,6 @@ basic_table() \%>\% # Another example: count the interaction between rows and columns into consideration -adsl <- cached_data$adsl -adqs <- cached_data$adqs adqs_single <- adqs \%>\% filter(AVISIT \%in\% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 5 DAY 36")) \%>\% droplevels() \%>\% diff --git a/man/summarize_variables_in_columns.Rd b/man/summarize_variables_in_columns.Rd index d9df082253..cc15a1cf9a 100644 --- a/man/summarize_variables_in_columns.Rd +++ b/man/summarize_variables_in_columns.Rd @@ -101,17 +101,15 @@ function which can be used for creating summary tables in columns, primarily use }} \examples{ - library(scda) library(dplyr) -ADPP <- scda::synthetic_cdisc_data("latest")$adpp \%>\% h_pkparam_sort() -summary_in_cols(ADPP$AGE, custom_label = "stats") - +adpp <- synthetic_cdisc_dataset("latest", "adpp") \%>\% h_pkparam_sort() +summary_in_cols(adpp$AGE, custom_label = "stats") lyt <- basic_table() \%>\% split_rows_by(var = "ARM", label_pos = "topleft") \%>\% split_rows_by(var = "SEX", label_pos = "topleft") \%>\% summarize_vars_in_cols(var = "AGE", col_split = TRUE) -result <- build_table(lyt = lyt, df = ADPP) +result <- build_table(lyt = lyt, df = adpp) result # By selecting just some statistics and ad-hoc labels @@ -132,7 +130,7 @@ lyt <- basic_table() \%>\% ), col_split = TRUE ) -result <- build_table(lyt = lyt, df = ADPP) +result <- build_table(lyt = lyt, df = adpp) result lyt <- basic_table() \%>\% @@ -141,7 +139,7 @@ lyt <- basic_table() \%>\% col_split = TRUE, custom_label = "some custom label" ) -result <- build_table(lyt, df = ADPP) +result <- build_table(lyt, df = adpp) result # PKPT03 @@ -163,7 +161,7 @@ lyt <- basic_table() \%>\% max = "Maximum" ) ) -result <- build_table(lyt, df = ADPP) +result <- build_table(lyt, df = adpp) result } \seealso{ diff --git a/man/survival_biomarkers_subgroups.Rd b/man/survival_biomarkers_subgroups.Rd index f4aea7d2ee..a648675637 100644 --- a/man/survival_biomarkers_subgroups.Rd +++ b/man/survival_biomarkers_subgroups.Rd @@ -84,7 +84,7 @@ library(dplyr) library(forcats) library(rtables) -adtte <- synthetic_cdisc_data("latest")$adtte +adtte <- synthetic_cdisc_dataset("latest", "adtte") # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) diff --git a/man/survival_coxph_pairwise.Rd b/man/survival_coxph_pairwise.Rd index 61c7de4f4f..c93f6f22c8 100644 --- a/man/survival_coxph_pairwise.Rd +++ b/man/survival_coxph_pairwise.Rd @@ -58,7 +58,8 @@ by a statistics function.} the helper function \code{\link[=control_coxph]{control_coxph()}}. Some possible parameter options are: \cr \itemize{ \item \code{pval_method}: (\code{string}) \cr p-value method for testing hazard ratio = 1. -Default method is "log-rank" which comes from \code{\link[survival:survdiff]{survival::survdiff()}}, can also be set to "wald" or "likelihood" that comes from \code{\link[survival:coxph]{survival::coxph()}}. +Default method is "log-rank" which comes from \code{\link[survival:survdiff]{survival::survdiff()}}, can also be set to "wald" or "likelihood" +that comes from \code{\link[survival:coxph]{survival::coxph()}}. \item \code{ties}: (\code{string}) \cr specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in \code{\link[survival:coxph]{survival::coxph()}} \item \code{conf_level}: (\code{proportion})\cr confidence level of the interval for HR. @@ -115,13 +116,13 @@ to the input layout. Note that additional formatting arguments can be used here. library(scda) library(dplyr) -ADTTE <- synthetic_cdisc_data("latest")$adtte -ADTTE_f <- ADTTE \%>\% +adtte <- synthetic_cdisc_dataset("latest", "adtte") +adtte_f <- adtte \%>\% filter(PARAMCD == "OS") \%>\% mutate(is_event = CNSR == 0) -df <- ADTTE_f \%>\% +df <- adtte_f \%>\% filter(ARMCD == "ARM A") -df_ref_group <- ADTTE_f \%>\% +df_ref_group <- adtte_f \%>\% filter(ARMCD == "ARM B") # Internal function - s_coxph_pairwise @@ -142,7 +143,7 @@ basic_table() \%>\% is_event = "is_event", var_labels = "Unstratified Analysis" ) \%>\% - build_table(df = ADTTE_f) + build_table(df = adtte_f) basic_table() \%>\% split_cols_by(var = "ARMCD", ref_group = "ARM A") \%>\% @@ -154,6 +155,6 @@ basic_table() \%>\% strat = "SEX", control = control_coxph(pval_method = "wald") ) \%>\% - build_table(df = ADTTE_f) + build_table(df = adtte_f) } \keyword{internal} diff --git a/man/survival_duration_subgroups.Rd b/man/survival_duration_subgroups.Rd index f63ad99e2f..b7498d6bf9 100644 --- a/man/survival_duration_subgroups.Rd +++ b/man/survival_duration_subgroups.Rd @@ -41,7 +41,8 @@ levels that belong to it in the character vectors that are elements of the list. the helper function \code{\link[=control_coxph]{control_coxph()}}. Some possible parameter options are: \cr \itemize{ \item \code{pval_method}: (\code{string}) \cr p-value method for testing hazard ratio = 1. -Default method is "log-rank" which comes from \code{\link[survival:survdiff]{survival::survdiff()}}, can also be set to "wald" or "likelihood" that comes from \code{\link[survival:coxph]{survival::coxph()}}. +Default method is "log-rank" which comes from \code{\link[survival:survdiff]{survival::survdiff()}}, can also be set to "wald" or "likelihood" +that comes from \code{\link[survival:coxph]{survival::coxph()}}. \item \code{ties}: (\code{string}) \cr specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more in \code{\link[survival:coxph]{survival::coxph()}} \item \code{conf_level}: (\code{proportion})\cr confidence level of the interval for HR. @@ -96,14 +97,13 @@ groupings for \code{subgroups} variables. }} \examples{ - # Testing dataset. library(scda) library(dplyr) library(forcats) library(rtables) -adtte <- synthetic_cdisc_data("latest")$adtte +adtte <- synthetic_cdisc_dataset("latest", "adtte") # Save variable labels before data processing steps. adtte_labels <- formatters::var_labels(adtte) diff --git a/man/survival_time.Rd b/man/survival_time.Rd index 30aa91df58..009f67d9a8 100644 --- a/man/survival_time.Rd +++ b/man/survival_time.Rd @@ -92,14 +92,14 @@ to the input layout. Note that additional formatting arguments can be used here. library(scda) library(dplyr) -ADTTE <- synthetic_cdisc_data("latest")$adtte -ADTTE_f <- ADTTE \%>\% +adtte <- synthetic_cdisc_dataset("latest", "adtte") +adtte_f <- adtte \%>\% filter(PARAMCD == "OS") \%>\% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) -df <- ADTTE_f \%>\% filter(ARMCD == "ARM A") +df <- adtte_f \%>\% filter(ARMCD == "ARM A") # Internal function - s_surv_time \dontrun{ @@ -120,6 +120,6 @@ basic_table() \%>\% is_event = "is_event", control = control_surv_time(conf_level = 0.9, conf_type = "log-log") ) \%>\% - build_table(df = ADTTE_f) + build_table(df = adtte_f) } \keyword{internal} diff --git a/man/survival_timepoint.Rd b/man/survival_timepoint.Rd index 0c9db6f01c..d9c59c17c6 100644 --- a/man/survival_timepoint.Rd +++ b/man/survival_timepoint.Rd @@ -148,14 +148,14 @@ Note that additional formatting arguments can be used here. library(scda) library(dplyr) -ADTTE <- synthetic_cdisc_data("latest")$adtte -ADTTE_f <- ADTTE \%>\% +adtte <- synthetic_cdisc_dataset("latest", "adtte") +adtte_f <- adtte \%>\% filter(PARAMCD == "OS") \%>\% mutate( AVAL = day2month(AVAL), is_event = CNSR == 0 ) -df <- ADTTE_f \%>\% +df <- adtte_f \%>\% filter(ARMCD == "ARM A") # Internal function - s_surv_timepoint @@ -168,7 +168,7 @@ s_surv_timepoint(df, .var = "AVAL", time_point = 7, is_event = "is_event") a_surv_timepoint(df, .var = "AVAL", time_point = 7, is_event = "is_event") } -df_ref_group <- ADTTE_f \%>\% +df_ref_group <- adtte_f \%>\% filter(ARMCD == "ARM B") # Internal function - s_surv_timepoint_diff @@ -207,7 +207,7 @@ basic_table() \%>\% is_event = "is_event", time_point = 7 ) \%>\% - build_table(df = ADTTE_f) + build_table(df = adtte_f) # Difference in survival at given time points. basic_table() \%>\% @@ -221,7 +221,7 @@ basic_table() \%>\% method = "surv_diff", .indent_mods = c("rate_diff" = 0L, "rate_diff_ci" = 2L, "ztest_pval" = 2L) ) \%>\% - build_table(df = ADTTE_f) + build_table(df = adtte_f) # Survival and difference in survival at given time points. basic_table() \%>\% @@ -234,6 +234,6 @@ basic_table() \%>\% time_point = 9, method = "both" ) \%>\% - build_table(df = ADTTE_f) + build_table(df = adtte_f) } \keyword{internal} diff --git a/tests/testthat/setup2-data.R b/tests/testthat/setup2-data.R index 10a5b57644..e94a43aeaa 100644 --- a/tests/testthat/setup2-data.R +++ b/tests/testthat/setup2-data.R @@ -1,24 +1,19 @@ # Data loading for tests -test_data_2022_02 <- scda::synthetic_cdisc_data("rcd_2022_02_28") -test_data_2022_06 <- scda::synthetic_cdisc_data("rcd_2022_06_27") - -adlb_raw <- test_data_2022_02$adlb -adsl_raw <- test_data_2022_02$adsl -adae_raw <- test_data_2022_02$adae -adaette_raw <- test_data_2022_02$adaette -adpp_raw <- test_data_2022_02$adpp -adpc_raw <- test_data_2022_02$adpc -adsub_raw <- test_data_2022_02$adsub -adqs_raw <- test_data_2022_02$adqs -adcm_raw <- test_data_2022_02$adcm -advs_raw <- test_data_2022_02$advs -adeg_raw <- test_data_2022_02$adeg -adex_raw <- test_data_2022_02$adex -adlb_raw <- test_data_2022_02$adlb -admh_raw <- test_data_2022_02$admh - -adrs_raw <- test_data_2022_06$adrs -adtte_raw <- test_data_2022_06$adtte +adsl_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adsl") +adae_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adae") +adaette_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adaette") +adpp_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adpp") +adpc_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adpc") +adsub_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adsub") +adqs_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adqs") +adcm_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adcm") +advs_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "advs") +adeg_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adeg") +adex_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adex") +adlb_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adlb") +admh_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "admh") +adrs_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adrs") +adtte_raw <- synthetic_cdisc_dataset("rcd_2022_06_27", "adtte") # Data as DM from `formatters` adsl_dm <- adsl_raw %>% diff --git a/tests/testthat/test-abnormal_by_worst_grade_worsen.R b/tests/testthat/test-abnormal_by_worst_grade_worsen.R index cb23213ab7..6b4392aabd 100644 --- a/tests/testthat/test-abnormal_by_worst_grade_worsen.R +++ b/tests/testthat/test-abnormal_by_worst_grade_worsen.R @@ -276,9 +276,9 @@ testthat::test_that("count_abnormal_lab_worsen_by_baseline", { "", "", "ALT", "High", "1", "2", "3", "4", "Any", "Low", "1", "2", "3", "4", "Any", "CRP", "Low", "1", "2", "3", "4", "Any", "IGA", "High", "1", "2", "3", "4", "Any", "ARM A", - "(N=134)", "", "", "16/119 (13.4%)", "14/123 (11.4%)", "9/127 (7.1%)", - "12/129 (9.3%)", "51/129 (39.5%)", "", "13/124 (10.5%)", "13/127 (10.2%)", - "19/128 (14.8%)", "7/130 (5.4%)", "52/130 (40%)", "", "", "14/122 (11.5%)", + "(N=134)", "", "", "16/121 (13.2%)", "14/125 (11.2%)", "9/129 (7%)", + "12/131 (9.2%)", "51/131 (38.9%)", "", "13/124 (10.5%)", "13/127 (10.2%)", + "19/129 (14.7%)", "7/131 (5.3%)", "52/131 (39.7%)", "", "", "14/122 (11.5%)", "21/124 (16.9%)", "12/129 (9.3%)", "10/131 (7.6%)", "57/131 (43.5%)", "", "", "24/118 (20.3%)", "13/120 (10.8%)", "11/124 (8.9%)", "11/129 (8.5%)", "59/129 (45.7%)", "ARM B", "(N=134)", "", "", @@ -287,11 +287,11 @@ testthat::test_that("count_abnormal_lab_worsen_by_baseline", { "7/131 (5.3%)", "48/131 (36.6%)", "", "", "17/125 (13.6%)", "12/130 (9.2%)", "9/131 (6.9%)", "7/133 (5.3%)", "45/133 (33.8%)", "", "", "12/120 (10%)", "19/124 (15.3%)", "10/128 (7.8%)", "13/130 (10%)", "54/130 (41.5%)", - "ARM C", "(N=132)", "", "", "17/116 (14.7%)", "17/119 (14.3%)", - "13/123 (10.6%)", "13/128 (10.2%)", "60/128 (46.9%)", "", "9/116 (7.8%)", - "11/123 (8.9%)", "10/127 (7.9%)", "10/131 (7.6%)", "40/131 (30.5%)", - "", "", "13/117 (11.1%)", "16/122 (13.1%)", "16/123 (13%)", "4/124 (3.2%)", - "49/124 (39.5%)", "", "", "13/119 (10.9%)", "13/125 (10.4%)", + "ARM C", "(N=132)", "", "", "17/117 (14.5%)", "17/120 (14.2%)", + "13/124 (10.5%)", "13/129 (10.1%)", "60/129 (46.5%)", "", "9/117 (7.7%)", + "11/124 (8.9%)", "10/128 (7.8%)", "10/132 (7.6%)", "40/132 (30.3%)", + "", "", "13/120 (10.8%)", "16/125 (12.8%)", "17/126 (13.5%)", "4/127 (3.1%)", + "50/127 (39.4%)", "", "", "13/119 (10.9%)", "13/125 (10.4%)", "17/128 (13.3%)", "4/130 (3.1%)", "47/130 (36.2%)" ), .Dim = c(29L, 4L) @@ -329,7 +329,6 @@ testthat::test_that("h_adlb_worsen all high", { }) testthat::test_that("h_adlb_worsen all low", { - adlb <- synthetic_cdisc_data("rcd_2022_02_28")$adlb adlb_local <- adlb_raw %>% dplyr::mutate( GRADDR = dplyr::case_when( diff --git a/tests/testthat/test-h_stack_by_baskets.R b/tests/testthat/test-h_stack_by_baskets.R index 40fbc82c61..1228655f86 100644 --- a/tests/testthat/test-h_stack_by_baskets.R +++ b/tests/testthat/test-h_stack_by_baskets.R @@ -26,7 +26,7 @@ testthat::test_that("h_stack_by_baskets returns the correct dataframe", { label = c(USUBJID = "Unique Subject Identifier") ), ASTDTM = structure( - c(1621814400, 1638230400, 1650499200, 1605312000), + c(1634947200, 1659484800, 1677888000, 1631404800), tzone = "", label = c(ASTDTM = "Analysis Start Datetime"), class = c("POSIXct", "POSIXt") diff --git a/tests/testthat/test-table_aet01.R b/tests/testthat/test-table_aet01.R index d4e5d700a9..ab02477042 100644 --- a/tests/testthat/test-table_aet01.R +++ b/tests/testthat/test-table_aet01.R @@ -103,17 +103,17 @@ testthat::test_that("Safety Summary Variant 1 works as expected", { "AE leading to withdrawal from treatment", "AE leading to dose modification/interruption", "Related AE", "Related AE leading to withdrawal from treatment", "Related AE leading to dose modification/interruption", "Grade 3-5 AE", - "A: Drug X", "(N=134)", "122 (91%)", "609", "22 (16.42%)", - "6 (4.48%)", "", "76 (56.7%)", "104 (77.6%)", "8 (6%)", - "36 (26.9%)", "76 (56.7%)", "23 (17.2%)", "72 (53.7%)", "105 (78.4%)", - "6 (4.5%)", "31 (23.1%)", "109 (81.3%)", "B: Placebo", "(N=134)", - "123 (91.8%)", "622", "26 (19.40%)", "1 (0.75%)", "", "70 (52.2%)", - "101 (75.4%)", "8 (6%)", "31 (23.1%)", "70 (52.2%)", "24 (17.9%)", - "65 (48.5%)", "108 (80.6%)", "9 (6.7%)", "31 (23.1%)", "104 (77.6%)", - "C: Combination", "(N=132)", "120 (90.9%)", "703", "19 (14.39%)", - "2 (1.52%)", "", "75 (56.8%)", "99 (75%)", "7 (5.3%)", "26 (19.7%)", - "75 (56.8%)", "27 (20.5%)", "76 (57.6%)", "109 (82.6%)", - "13 (9.8%)", "32 (24.2%)", "109 (82.6%)" + "A: Drug X", "(N=134)", "122 (91%)", "609", "25 (18.66%)", + "3 (2.24%)", "", "76 (56.7%)", "104 (77.6%)", "9 (6.7%)", + "22 (16.4%)", "76 (56.7%)", "27 (20.1%)", "66 (49.3%)", "105 (78.4%)", + "6 (4.5%)", "29 (21.6%)", "109 (81.3%)", "B: Placebo", "(N=134)", + "123 (91.8%)", "622", "23 (17.16%)", "6 (4.48%)", "", "70 (52.2%)", + "101 (75.4%)", "6 (4.5%)", "26 (19.4%)", "70 (52.2%)", "26 (19.4%)", + "76 (56.7%)", "108 (80.6%)", "12 (9%)", "38 (28.4%)", "104 (77.6%)", + "C: Combination", "(N=132)", "120 (90.9%)", "703", "22 (16.67%)", + "5 (3.79%)", "", "75 (56.8%)", "99 (75%)", "11 (8.3%)", "29 (22%)", + "75 (56.8%)", "30 (22.7%)", "74 (56.1%)", "109 (82.6%)", + "8 (6.1%)", "38 (28.8%)", "109 (82.6%)" ), .Dim = c(18L, 4L) ) @@ -252,18 +252,18 @@ testthat::test_that("Safety Summary Variant 2 (with Medical Concepts Section) wo "Related AE leading to dose modification/interruption", "Grade 3-5 AE", "Total number of patients with at least one", "C.1.1.1.3/B.2.2.3.1 AESI (BROAD)", "SMQ 02 Reference Name", "D.2.1.5.3/A.1.1.1.1 AESI", "A: Drug X", - "(N=134)", "122 (91%)", "609", "22 (16.42%)", "6 (4.48%)", - "", "76 (56.7%)", "104 (77.6%)", "8 (6%)", "36 (26.9%)", - "76 (56.7%)", "23 (17.2%)", "72 (53.7%)", "105 (78.4%)", - "6 (4.5%)", "31 (23.1%)", "109 (81.3%)", "", "72 (53.7%)", + "(N=134)", "122 (91%)", "609", "25 (18.66%)", "3 (2.24%)", + "", "76 (56.7%)", "104 (77.6%)", "9 (6.7%)", "22 (16.4%)", + "76 (56.7%)", "27 (20.1%)", "66 (49.3%)", "105 (78.4%)", + "6 (4.5%)", "29 (21.6%)", "109 (81.3%)", "", "72 (53.7%)", "0", "74 (55.2%)", "B: Placebo", "(N=134)", "123 (91.8%)", - "622", "26 (19.40%)", "1 (0.75%)", "", "70 (52.2%)", "101 (75.4%)", - "8 (6%)", "31 (23.1%)", "70 (52.2%)", "24 (17.9%)", "65 (48.5%)", - "108 (80.6%)", "9 (6.7%)", "31 (23.1%)", "104 (77.6%)", "", + "622", "23 (17.16%)", "6 (4.48%)", "", "70 (52.2%)", "101 (75.4%)", + "6 (4.5%)", "26 (19.4%)", "70 (52.2%)", "26 (19.4%)", "76 (56.7%)", + "108 (80.6%)", "12 (9%)", "38 (28.4%)", "104 (77.6%)", "", "79 (59%)", "0", "80 (59.7%)", "C: Combination", "(N=132)", - "120 (90.9%)", "703", "19 (14.39%)", "2 (1.52%)", "", "75 (56.8%)", - "99 (75%)", "7 (5.3%)", "26 (19.7%)", "75 (56.8%)", "27 (20.5%)", - "76 (57.6%)", "109 (82.6%)", "13 (9.8%)", "32 (24.2%)", "109 (82.6%)", + "120 (90.9%)", "703", "22 (16.67%)", "5 (3.79%)", "", "75 (56.8%)", + "99 (75%)", "11 (8.3%)", "29 (22%)", "75 (56.8%)", "30 (22.7%)", + "74 (56.1%)", "109 (82.6%)", "8 (6.1%)", "38 (28.8%)", "109 (82.6%)", "", "75 (56.8%)", "0", "87 (65.9%)" ), .Dim = c(22L, 4L) @@ -368,14 +368,14 @@ testthat::test_that("Safety Summary Variant 3 (with Modified Rows) works as expe "Total number of patients withdrawn informed consent", "Total number of patients with at least one", "AE with fatal outcome", "Serious AE", "AE leading to withdrawal from treatment", "Related AE", "Grade 3-5 AE", "Grade 4/5 AE", "A: Drug X", "(N=134)", - "122 (91%)", "609", "22 (16.42%)", "6 (4.48%)", "2 (1.49%)", - "", "76 (56.7%)", "104 (77.6%)", "23 (17.2%)", "105 (78.4%)", + "122 (91%)", "609", "25 (18.66%)", "3 (2.24%)", "1 (0.75%)", + "", "76 (56.7%)", "104 (77.6%)", "27 (20.1%)", "105 (78.4%)", "109 (81.3%)", "91 (67.9%)", "B: Placebo", "(N=134)", "123 (91.8%)", - "622", "26 (19.40%)", "1 (0.75%)", "2 (1.49%)", "", "70 (52.2%)", - "101 (75.4%)", "24 (17.9%)", "108 (80.6%)", "104 (77.6%)", + "622", "23 (17.16%)", "6 (4.48%)", "1 (0.75%)", "", "70 (52.2%)", + "101 (75.4%)", "26 (19.4%)", "108 (80.6%)", "104 (77.6%)", "90 (67.2%)", "C: Combination", "(N=132)", "120 (90.9%)", "703", - "19 (14.39%)", "2 (1.52%)", "0 (0.00%)", "", "75 (56.8%)", "99 (75%)", - "27 (20.5%)", "109 (82.6%)", "109 (82.6%)", "93 (70.5%)" + "22 (16.67%)", "5 (3.79%)", "1 (0.76%)", "", "75 (56.8%)", "99 (75%)", + "30 (22.7%)", "109 (82.6%)", "109 (82.6%)", "93 (70.5%)" ), .Dim = c(14L, 4L) ) @@ -504,17 +504,17 @@ testthat::test_that("Safety Summary Variant 4 (with Rows Counting Events and Add "Related AE", "Grade 3-5 AE", "Grade 4/5", "Total number of adverse events which are", "Serious AE", "AE leading to dose modification/interruption", "Related AE", "Grade 3-5 AE", "Grade 4/5", "A: Drug X", "(N=134)", - "122 (91%)", "609", "22 (16.42%)", "6 (4.48%)", "", "76 (56.7%)", - "104 (77.6%)", "23 (17.2%)", "72 (53.7%)", "105 (78.4%)", - "109 (81.3%)", "", "4", "8", "5", "5", "3", "", "249", "109", + "122 (91%)", "609", "25 (18.66%)", "3 (2.24%)", "", "76 (56.7%)", + "104 (77.6%)", "27 (20.1%)", "66 (49.3%)", "105 (78.4%)", + "109 (81.3%)", "", "4", "8", "5", "5", "3", "", "249", "116", "282", "303", "172", "B: Placebo", "(N=134)", "123 (91.8%)", - "622", "26 (19.40%)", "1 (0.75%)", "", "70 (52.2%)", "101 (75.4%)", - "24 (17.9%)", "65 (48.5%)", "108 (80.6%)", "104 (77.6%)", - "", "4", "8", "5", "5", "3", "", "255", "100", "299", "291", - "174", "C: Combination", "(N=132)", "120 (90.9%)", "703", "19 (14.39%)", - "2 (1.52%)", "", "75 (56.8%)", "99 (75%)", "27 (20.5%)", "76 (57.6%)", + "622", "23 (17.16%)", "6 (4.48%)", "", "70 (52.2%)", "101 (75.4%)", + "26 (19.4%)", "76 (56.7%)", "108 (80.6%)", "104 (77.6%)", + "", "4", "8", "5", "5", "3", "", "255", "122", "299", "291", + "174", "C: Combination", "(N=132)", "120 (90.9%)", "703", "22 (16.67%)", + "5 (3.79%)", "", "75 (56.8%)", "99 (75%)", "30 (22.7%)", "74 (56.1%)", "109 (82.6%)", "109 (82.6%)", "", "4", "8", "5", "5", "3", - "", "282", "138", "336", "327", "197" + "", "282", "137", "336", "327", "197" ), .Dim = c(25L, 4L) ) diff --git a/tests/testthat/test-table_aet05.R b/tests/testthat/test-table_aet05.R index bf9585bcb1..d8c7441eaa 100644 --- a/tests/testthat/test-table_aet05.R +++ b/tests/testthat/test-table_aet05.R @@ -22,10 +22,10 @@ testthat::test_that("AET05 variant 1 is produced correctly", { c( "", "", "Total patient-years at risk", "Number of adverse events observed", "AE rate per 100 patient-years", - "95% CI", "A: Drug X", "(N=134)", "112.3", "78", "69.49", - "(54.07, 84.91)", "B: Placebo", "(N=134)", "77.4", "104", "134.37", - "(108.54, 160.19)", "C: Combination", "(N=132)", "119.4", "67", "56.10", - "(42.67, 69.53)" + "95% CI", "A: Drug X", "(N=134)", "162.4", "78", "48.03", + "(37.37, 58.69)", "B: Placebo", "(N=134)", "103.8", "104", "100.15", + "(80.90, 119.40)", "C: Combination", "(N=132)", "172.6", "67", "38.82", + "(29.53, 48.12)" ), .Dim = c(6L, 4L) ) @@ -53,10 +53,10 @@ testthat::test_that("AET05 variant 2 is produced correctly", { c( "", "", "Total patient-years at risk", "Number of adverse events observed", "AE rate per 100 patient-years", - "95% CI", "A: Drug X", "(N=134)", "112.3", "78", "69.49", - "(54.93, 86.72)", "B: Placebo", "(N=134)", "77.4", "104", "134.37", - "(109.79, 162.81)", "C: Combination", "(N=132)", "119.4", "67", "56.10", - "(43.48, 71.25)" + "95% CI", "A: Drug X", "(N=134)", "162.4", "78", "48.03", + "(37.97, 59.94)", "B: Placebo", "(N=134)", "103.8", "104", "100.15", + "(81.83, 121.35)", "C: Combination", "(N=132)", "172.6", "67", "38.82", + "(30.09, 49.30)" ), .Dim = c(6L, 4L) ) diff --git a/tests/testthat/test-table_coxt01.R b/tests/testthat/test-table_coxt01.R index 544863b666..e3e1b24548 100644 --- a/tests/testthat/test-table_coxt01.R +++ b/tests/testthat/test-table_coxt01.R @@ -1,12 +1,12 @@ # nolint start -ADTTE <- adtte_raw -saved_labels <- formatters::var_labels(ADTTE) +adtte <- adtte_raw +saved_labels <- formatters::var_labels(adtte) -ADTTE_f <- subset(ADTTE, PARAMCD == "OS") # _f: filtered -ADTTE_f <- within( +adtte_f <- subset(adtte, PARAMCD == "OS") # _f: filtered +adtte_f <- within( data = subset( - ADTTE_f, + adtte_f, PARAMCD == "OS" & ARMCD %in% c("ARM A", "ARM B") & SEX %in% c("F", "M") & @@ -19,8 +19,8 @@ ADTTE_f <- within( RACE <- droplevels(RACE) } ) -formatters::var_labels(ADTTE_f) <- saved_labels -ADTTE_f$event <- 1 - ADTTE_f$CNSR +formatters::var_labels(adtte_f) <- saved_labels +adtte_f$event <- 1 - adtte_f$CNSR # nolint end testthat::test_that("1. Cox Regression", { @@ -29,7 +29,7 @@ testthat::test_that("1. Cox Regression", { time = "AVAL", event = "event", arm = "ARMCD", covariates = c("SEX", "RACE", "AGE") ), - data = ADTTE_f + data = adtte_f ) df <- broom::tidy(mod1) result <- basic_table() %>% @@ -59,7 +59,7 @@ testthat::test_that("2. Cox Regression (with Interaction Term)", { time = "AVAL", event = "event", arm = "ARMCD", covariates = c("SEX", "RACE", "AGE") ), - data = ADTTE_f, + data = adtte_f, control = control_coxreg(interaction = TRUE) ) df <- broom::tidy(mod2) @@ -95,7 +95,7 @@ testthat::test_that("3. Cox Regression (specifying covariates)", { time = "AVAL", event = "event", arm = "ARMCD", covariates = c("SEX", "RACE", "AGE") ), - data = ADTTE_f, + data = adtte_f, control = control_coxreg(interaction = TRUE), at = list(AGE = c(30, 40, 50)) ) @@ -136,7 +136,7 @@ testthat::test_that("4. Cox Regression (setting strata, ties, and alpha level)", time = "AVAL", event = "event", arm = "ARMCD", covariates = c("SEX", "RACE", "AGE") ), - data = ADTTE_f, + data = adtte_f, control = control_coxreg( interaction = TRUE, conf_level = conf_level, diff --git a/tests/testthat/test-table_disclosures.R b/tests/testthat/test-table_disclosures.R index 7cfcaf6f23..0cc3e884d7 100644 --- a/tests/testthat/test-table_disclosures.R +++ b/tests/testthat/test-table_disclosures.R @@ -109,16 +109,16 @@ testthat::test_that("Patient Disposition table is produced correctly", { "", "", "Started Study", "Completed Study", "Discontinued Study", "ADVERSE EVENT", "DEATH", "LACK OF EFFICACY", "PHYSICIAN DECISION", "PROTOCOL VIOLATION", "WITHDRAWAL BY PARENT/GUARDIAN", "WITHDRAWAL BY SUBJECT", - "A: Drug X", "(N=134)", "134 (100.00%)", "69 (51.49%)", "38 (28.36%)", - "6 (4.48%)", "22 (16.42%)", "2 (1.49%)", "0 (0.00%)", "4 (2.99%)", - "2 (1.49%)", "2 (1.49%)", "B: Placebo", "(N=134)", "134 (100.00%)", - "69 (51.49%)", "43 (32.09%)", "1 (0.75%)", "26 (19.40%)", "1 (0.75%)", - "1 (0.75%)", "7 (5.22%)", "5 (3.73%)", "2 (1.49%)", "C: Combination", - "(N=132)", "132 (100.00%)", "72 (54.55%)", "39 (29.55%)", "2 (1.52%)", - "19 (14.39%)", "2 (1.52%)", "7 (5.30%)", "6 (4.55%)", "3 (2.27%)", - "0 (0.00%)", "All Patients", "(N=400)", "400 (100.00%)", "210 (52.50%)", - "120 (30.00%)", "9 (2.25%)", "67 (16.75%)", "5 (1.25%)", "8 (2.00%)", - "17 (4.25%)", "10 (2.50%)", "4 (1.00%)" + "A: Drug X", "(N=134)", "134 (100.00%)", "68 (50.75%)", "42 (31.34%)", + "3 (2.24%)", "25 (18.66%)", "2 (1.49%)", "2 (1.49%)", "5 (3.73%)", + "4 (2.99%)", "1 (0.75%)", "B: Placebo", "(N=134)", "134 (100.00%)", + "66 (49.25%)", "40 (29.85%)", "6 (4.48%)", "23 (17.16%)", "2 (1.49%)", + "3 (2.24%)", "3 (2.24%)", "2 (1.49%)", "1 (0.75%)", "C: Combination", + "(N=132)", "132 (100.00%)", "73 (55.30%)", "38 (28.79%)", "5 (3.79%)", + "22 (16.67%)", "3 (2.27%)", "2 (1.52%)", "4 (3.03%)", "1 (0.76%)", + "1 (0.76%)", "All Patients", "(N=400)", "400 (100.00%)", "207 (51.75%)", + "120 (30.00%)", "14 (3.50%)", "70 (17.50%)", "7 (1.75%)", "7 (1.75%)", + "12 (3.00%)", "7 (1.75%)", "3 (0.75%)" ), .Dim = c(12L, 5L) ) diff --git a/tests/testthat/test-table_dth01.R b/tests/testthat/test-table_dth01.R index 5f002f2bb8..2b5b8a83c9 100644 --- a/tests/testthat/test-table_dth01.R +++ b/tests/testthat/test-table_dth01.R @@ -23,12 +23,12 @@ testthat::test_that("DTH01 variant 1 is produced correctly", { c( "", "", "Total number of deaths", "Primary cause of death", "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", "A: Drug X", - "(N=134)", "22 (16.4%)", "", "22", "6 (27.3%)", "9 (40.9%)", - "7 (31.8%)", "B: Placebo", "(N=134)", "26 (19.4%)", "", "26", - "12 (46.2%)", "5 (19.2%)", "9 (34.6%)", "C: Combination", "(N=132)", - "19 (14.4%)", "", "19", "7 (36.8%)", "4 (21.1%)", "8 (42.1%)", - "All Patients", "(N=400)", "67 (16.8%)", "", "67", "25 (37.3%)", - "18 (26.9%)", "24 (35.8%)" + "(N=134)", "25 (18.7%)", "", "25", "9 (36%)", "8 (32%)", + "8 (32%)", "B: Placebo", "(N=134)", "23 (17.2%)", "", "23", + "7 (30.4%)", "10 (43.5%)", "6 (26.1%)", "C: Combination", "(N=132)", + "22 (16.7%)", "", "22", "10 (45.5%)", "6 (27.3%)", "6 (27.3%)", + "All Patients", "(N=400)", "70 (17.5%)", "", "70", "26 (37.1%)", + "24 (34.3%)", "20 (28.6%)" ), .Dim = c(8L, 5L) ) @@ -94,30 +94,28 @@ testthat::test_that("DTH01 variant 2 is produced correctly", { expected <- structure( c( "", "", "Total number of deaths", "Primary cause of death", - "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", "LOST TO FOLLOW UP", - "MISSING", "SUICIDE", "UNKNOWN", "Days from last drug administration", + "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", "LOST TO FOLLOW UP", "MISSING", + "Post-study reporting of death", "SUICIDE", "UNKNOWN", "Days from last drug administration", "n", "<=30", ">30", "Primary cause by days from last study drug administration", "<=30", "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", ">30", "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", - "A: Drug X", "(N=134)", "22 (16.4%)", "", "22", "6 (27.3%)", - "9 (40.9%)", "7 (31.8%)", "2 (22.2%)", "4 (44.4%)", "2 (22.2%)", - "1 (11.1%)", "", "22", "12 (54.5%)", "10 (45.5%)", "", "", "12", - "3 (25%)", "6 (50%)", "3 (25%)", "", "10", "3 (30%)", "3 (30%)", - "4 (40%)", "B: Placebo", "(N=134)", "26 (19.4%)", "", "26", "12 (46.2%)", - "5 (19.2%)", "9 (34.6%)", "2 (40%)", "1 (20%)", "1 (20%)", "1 (20%)", - "", "26", "16 (61.5%)", "10 (38.5%)", "", "", "16", "9 (56.2%)", - "3 (18.8%)", "4 (25%)", "", "10", "3 (30%)", "2 (20%)", "5 (50%)", - "C: Combination", "(N=132)", "19 (14.4%)", "", "19", "7 (36.8%)", - "4 (21.1%)", "8 (42.1%)", "1 (25%)", "2 (50%)", "1 (25%)", "0", - "", "19", "10 (52.6%)", "9 (47.4%)", "", "", "10", "4 (40%)", - "3 (30%)", "3 (30%)", "", "9", "3 (33.3%)", "1 (11.1%)", "5 (55.6%)", - "All Patients", "(N=400)", "67 (16.8%)", "", "67", "25 (37.3%)", - "18 (26.9%)", "24 (35.8%)", "5 (27.8%)", "7 (38.9%)", "4 (22.2%)", - "2 (11.1%)", "", "67", "38 (56.7%)", "29 (43.3%)", "", "", "38", - "16 (42.1%)", "12 (31.6%)", "10 (26.3%)", "", "29", "9 (31%)", - "6 (20.7%)", "14 (48.3%)" + "A: Drug X", "(N=134)", "25 (18.7%)", "", "25", "9 (36%)", + "8 (32%)", "8 (32%)", "2 (25%)", "2 (25%)", "1 (12.5%)", + "2 (25%)", "1 (12.5%)", "", "25", "14 (56%)", "11 (44%)", "", "", "14", + "4 (28.6%)", "4 (28.6%)", "6 (42.9%)", "", "11", "5 (45.5%)", "4 (36.4%)", + "2 (18.2%)", "B: Placebo", "(N=134)", "23 (17.2%)", "", "23", "7 (30.4%)", + "10 (43.5%)", "6 (26.1%)", "2 (20%)", "3 (30%)", "2 (20%)", "2 (20%)", "1 (10%)", + "", "23", "11 (47.8%)", "12 (52.2%)", "", "", "11", "2 (18.2%)", + "6 (54.5%)", "3 (27.3%)", "", "12", "5 (41.7%)", "4 (33.3%)", "3 (25%)", + "C: Combination", "(N=132)", "22 (16.7%)", "", "22", "10 (45.5%)", + "6 (27.3%)", "6 (27.3%)", "2 (33.3%)", "2 (33.3%)", "1 (16.7%)", "1 (16.7%)", "0", + "", "22", "14 (63.6%)", "8 (36.4%)", "", "", "14", "6 (42.9%)", "4 (28.6%)", "4 (28.6%)", "", "8", + "4 (50%)", "2 (25%)", "2 (25%)", "All Patients", "(N=400)", "70 (17.5%)", "", "70", "26 (37.1%)", + "24 (34.3%)", "20 (28.6%)", "6 (25%)", "7 (29.2%)", "4 (16.7%)", "5 (20.8%)", + "2 (8.3%)", "", "70", "39 (55.7%)", "31 (44.3%)", "", "", "39", + "12 (30.8%)", "14 (35.9%)", "13 (33.3%)", "", "31", "14 (45.2%)", "10 (32.3%)", "7 (22.6%)" ), - .Dim = c(27L, 5L) + .Dim = c(28L, 5L) ) testthat::expect_identical(result, expected) }) @@ -182,14 +180,14 @@ testthat::test_that("DTH01 variant 3 is produced correctly", { c( "", "", "Total number of deaths", "Primary cause of death", "n", "ADVERSE EVENT", "PROGRESSIVE DISEASE", "OTHER", "Post study reporting of deaths", - "All other causes", "A: Drug X", "(N=134)", "22 (16.4%)", "", - "22", "6 (27.3%)", "7 (31.8%)", "9 (40.9%)", "2 (22.2%)", "7 (77.8%)", - "B: Placebo", "(N=134)", "26 (19.4%)", "", "26", "12 (46.2%)", - "9 (34.6%)", "5 (19.2%)", "1 (20.0%)", "4 (80.0%)", "C: Combination", - "(N=132)", "19 (14.4%)", "", "19", "7 (36.8%)", "8 (42.1%)", - "4 (21.1%)", "1 (25.0%)", "3 (75.0%)", "All Patients", "(N=400)", - "67 (16.8%)", "", "67", "25 (37.3%)", "24 (35.8%)", "18 (26.9%)", - "4 (22.2%)", "14 (77.8%)" + "All other causes", "A: Drug X", "(N=134)", "25 (18.7%)", "", + "25", "9 (36%)", "8 (32%)", "8 (32%)", "1 (12.5%)", "7 (87.5%)", + "B: Placebo", "(N=134)", "23 (17.2%)", "", "23", "7 (30.4%)", + "6 (26.1%)", "10 (43.5%)", "2 (20.0%)", "8 (80.0%)", "C: Combination", + "(N=132)", "22 (16.7%)", "", "22", "10 (45.5%)", "6 (27.3%)", + "6 (27.3%)", "1 (16.7%)", "5 (83.3%)", "All Patients", "(N=400)", + "70 (17.5%)", "", "70", "26 (37.1%)", "20 (28.6%)", "24 (34.3%)", + "4 (16.7%)", "20 (83.3%)" ), .Dim = c(10L, 5L) ) @@ -277,16 +275,16 @@ testthat::test_that("DTH01 variant 4 is produced correctly", { "", "", "Total number of deaths", "Primary cause of death", "n", "ADVERSE EVENT", "PROGRESSIVE DISEASE", "OTHER", "Post study reporting of deaths", "All other causes", "LOST TO FOLLOW UP", "SUICIDE", "UNKNOWN", - "MISSING", "A: Drug X", "(N=134)", "22 (16.4%)", "", "22", "6 (27.3%)", - "7 (31.8%)", "9 (40.9%)", "2 (22.2%)", "7 (77.8%)", "2 (22.2%)", - "2 (22.2%)", "1 (11.1%)", "4 (44.4%)", "B: Placebo", "(N=134)", - "26 (19.4%)", "", "26", "12 (46.2%)", "9 (34.6%)", "5 (19.2%)", - "1 (20.0%)", "4 (80.0%)", "2 (40%)", "1 (20%)", "1 (20%)", "1 (20%)", - "C: Combination", "(N=132)", "19 (14.4%)", "", "19", "7 (36.8%)", - "8 (42.1%)", "4 (21.1%)", "1 (25.0%)", "3 (75.0%)", "1 (25%)", "1 (25%)", - "0", "2 (50%)", "All Patients", "(N=400)", "67 (16.8%)", "", - "67", "25 (37.3%)", "24 (35.8%)", "18 (26.9%)", "4 (22.2%)", - "14 (77.8%)", "5 (27.8%)", "4 (22.2%)", "2 (11.1%)", "7 (38.9%)" + "MISSING", "A: Drug X", "(N=134)", "25 (18.7%)", "", "25", "9 (36%)", + "8 (32%)", "8 (32%)", "1 (12.5%)", "7 (87.5%)", "2 (28.6%)", + "2 (28.6%)", "1 (14.3%)", "2 (28.6%)", "B: Placebo", "(N=134)", + "23 (17.2%)", "", "23", "7 (30.4%)", "6 (26.1%)", "10 (43.5%)", + "2 (20.0%)", "8 (80.0%)", "2 (25%)", "2 (25%)", "1 (12.5%)", "3 (37.5%)", + "C: Combination", "(N=132)", "22 (16.7%)", "", "22", "10 (45.5%)", + "6 (27.3%)", "6 (27.3%)", "1 (16.7%)", "5 (83.3%)", "2 (40%)", "1 (20%)", + "0", "2 (40%)", "All Patients", "(N=400)", "70 (17.5%)", "", + "70", "26 (37.1%)", "20 (28.6%)", "24 (34.3%)", "4 (16.7%)", + "20 (83.3%)", "6 (30%)", "5 (25%)", "2 (10%)", "7 (35%)" ), .Dim = c(14L, 5L) ) diff --git a/tests/testthat/test-table_egt03.R b/tests/testthat/test-table_egt03.R index 3891d3a981..9188280513 100644 --- a/tests/testthat/test-table_egt03.R +++ b/tests/testthat/test-table_egt03.R @@ -16,7 +16,6 @@ testthat::test_that("EGT03 variant 1 is produced correctly", { AVISIT == "POST-BASELINE MINIMUM" # "Analysis Visit" ) - # Preprocessing # For the EGT03 template, data imputation shoud be avoided, and missing data @@ -51,18 +50,18 @@ testthat::test_that("EGT03 variant 1 is produced correctly", { expected_matrix <- structure( c( - "", "A: Drug X (N=133)", "n", "LOW", "NORMAL", "HIGH", + "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", "Missing", "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", "Missing", "C: Combination (N=132)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "LOW", "", "39", "1 (0.8%)", "35 (26.3%)", "3 (2.3%)", - "0", "", "43", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "1 (0.7%)", - "", "37", "4 (3%)", "30 (22.7%)", "1 (0.8%)", "2 (1.5%)", "NORMAL", - "", "90", "3 (2.3%)", "83 (62.4%)", "4 (3%)", "0", "", "91", - "9 (6.7%)", "77 (57.5%)", "4 (3%)", "1 (0.7%)", "", "94", "11 (8.3%)", + "Missing", "LOW", "", "40", "1 (0.7%)", "36 (26.9%)", "2 (1.5%)", + "1 (0.7%)", "", "43", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "1 (0.7%)", + "", "37", "4 (3%)", "31 (23.5%)", "1 (0.8%)", "1 (0.8%)", "NORMAL", + "", "92", "5 (3.7%)", "83 (61.9%)", "4 (3%)", "0", "", "89", + "9 (6.7%)", "75 (56%)", "4 (3%)", "1 (0.7%)", "", "94", "11 (8.3%)", "75 (56.8%)", "8 (6.1%)", "0", "HIGH", "", "0", "0", "0", "0", "0", "", "0", "0", "0", "0", "0", "", "0", "0", "0", "0", "0", - "Missing", "", "4", "2 (1.5%)", "1 (0.8%)", "0", "1 (0.8%)", - "", "0", "0", "0", "0", "0", "", "1", "0", "0", "1 (0.8%)", "0" + "Missing", "", "2", "0", "1 (0.7%)", "0", "1 (0.7%)", + "", "2", "0", "2 (1.5%)", "0", "0", "", "1", "0", "0", "1 (0.8%)", "0" ), .Dim = c(19L, 5L) ) @@ -70,8 +69,6 @@ testthat::test_that("EGT03 variant 1 is produced correctly", { testthat::expect_identical(result_matrix, expected_matrix) }) - - testthat::test_that("EGT03 variant 2 is produced correctly", { set.seed(123, kind = "Mersenne-Twister") adeg_labels <- formatters::var_labels(adeg) @@ -86,7 +83,6 @@ testthat::test_that("EGT03 variant 2 is produced correctly", { AVISIT == "POST-BASELINE MINIMUM" # "Analysis Visit" ) - # Preprocessing # For the EGT03 template, data imputation shoud be avoided, and missing data @@ -114,13 +110,13 @@ testthat::test_that("EGT03 variant 2 is produced correctly", { expected_matrix <- structure( c( - "", "A: Drug X (N=133)", "n", "LOW", "NORMAL", "HIGH", + "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", "Missing", "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", "Missing", "C: Combination (N=132)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "LOW", "", "39", "1 (0.8%)", "35 (26.3%)", "3 (2.3%)", - "0", "", "43", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "1 (0.7%)", - "", "37", "4 (3%)", "30 (22.7%)", "1 (0.8%)", "2 (1.5%)", "NORMAL", - "", "94", "5 (3.8%)", "84 (63.2%)", "4 (3%)", "1 (0.8%)", "", + "Missing", "LOW", "", "40", "1 (0.7%)", "36 (26.9%)", "2 (1.5%)", + "1 (0.7%)", "", "43", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "1 (0.7%)", + "", "37", "4 (3%)", "31 (23.5%)", "1 (0.8%)", "1 (0.8%)", "NORMAL", + "", "94", "5 (3.7%)", "84 (62.7%)", "4 (3%)", "1 (0.7%)", "", "91", "9 (6.7%)", "77 (57.5%)", "4 (3%)", "1 (0.7%)", "", "95", "11 (8.3%)", "75 (56.8%)", "9 (6.8%)", "0", "HIGH", "", "0", "0", "0", "0", "0", "", "0", "0", "0", "0", "0", "", "0", "0", @@ -132,7 +128,6 @@ testthat::test_that("EGT03 variant 2 is produced correctly", { testthat::expect_identical(result_matrix, expected_matrix) }) - testthat::test_that("EGT03 variant 3 is produced correctly", { set.seed(123, kind = "Mersenne-Twister") adeg_labels <- formatters::var_labels(adeg) @@ -147,7 +142,6 @@ testthat::test_that("EGT03 variant 3 is produced correctly", { AVISIT == "POST-BASELINE MINIMUM" # "Analysis Visit" ) - # Preprocessing # For the EGT03 template, data imputation shoud be avoided, and missing data @@ -175,16 +169,16 @@ testthat::test_that("EGT03 variant 3 is produced correctly", { expected_matrix <- structure( c( - "", "A: Drug X (N=133)", "n", "LOW", "NORMAL", "HIGH", + "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", "C: Combination (N=132)", - "n", "LOW", "NORMAL", "HIGH", "LOW", "", "39", "1 (0.8%)", "35 (26.3%)", - "3 (2.3%)", "", "42", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "", - "35", "4 (3%)", "30 (22.7%)", "1 (0.8%)", "NORMAL", "", "93", - "5 (3.8%)", "84 (63.2%)", "4 (3%)", "", "90", "9 (6.7%)", "77 (57.5%)", + "n", "LOW", "NORMAL", "HIGH", "LOW", "", "39", "1 (0.7%)", "36 (26.9%)", + "2 (1.5%)", "", "42", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "", + "36", "4 (3%)", "31 (23.5%)", "1 (0.8%)", "NORMAL", "", "93", + "5 (3.7%)", "84 (62.7%)", "4 (3%)", "", "90", "9 (6.7%)", "77 (57.5%)", "4 (3%)", "", "95", "11 (8.3%)", "75 (56.8%)", "9 (6.8%)", "HIGH", "", "0", "0", "0", "0", "", "0", "0", "0", "0", "", "0", "0", - "0", "0", "Missing", "", "1", "0", "1 (0.8%)", "0", "", "2", - "0", "2 (1.5%)", "0", "", "2", "0", "2 (1.5%)", "0" + "0", "0", "Missing", "", "2", "0", "1 (0.7%)", "1 (0.7%)", "", "2", + "0", "2 (1.5%)", "0", "", "1", "0", "1 (0.8%)", "0" ), .Dim = c(16L, 5L) ) @@ -192,7 +186,6 @@ testthat::test_that("EGT03 variant 3 is produced correctly", { testthat::expect_identical(result_matrix, expected_matrix) }) - testthat::test_that("EGT03 variant 4 is produced correctly", { set.seed(123, kind = "Mersenne-Twister") adeg_labels <- formatters::var_labels(adeg) @@ -207,7 +200,6 @@ testthat::test_that("EGT03 variant 4 is produced correctly", { AVISIT == "POST-BASELINE MAXIMUM" # "Analysis Visit" ) - # Preprocessing # For the EGT03 template, data imputation shoud be avoided, and missing data @@ -227,7 +219,6 @@ testthat::test_that("EGT03 variant 4 is produced correctly", { adeg_f$BNRIND[sample(seq_len(nrow(adeg_f)), size = 5)] <- "Missing" adeg_f$ANRIND[sample(seq_len(nrow(adeg_f)), size = 5)] <- "Missing" - formatters::var_labels(adeg_f) <- adeg_labels lyt <- basic_table() %>% @@ -242,18 +233,18 @@ testthat::test_that("EGT03 variant 4 is produced correctly", { expected_matrix <- structure( c( - "", "A: Drug X (N=133)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "B: Placebo (N=133)", "n", "LOW", "NORMAL", "HIGH", + "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", + "Missing", "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", "Missing", "C: Combination (N=132)", "n", "LOW", "NORMAL", "HIGH", "Missing", "LOW", "", "0", "0", "0", "0", "0", "", "0", "0", - "0", "0", "0", "", "0", "0", "0", "0", "0", "NORMAL", "", "94", - "2 (1.5%)", "87 (65.4%)", "5 (3.8%)", "0", "", "88", "8 (6%)", - "76 (57.1%)", "3 (2.3%)", "1 (0.8%)", "", "95", "11 (8.3%)", - "78 (59.1%)", "5 (3.8%)", "1 (0.8%)", "HIGH", "", "37", "4 (3%)", - "30 (22.6%)", "2 (1.5%)", "1 (0.8%)", "", "43", "2 (1.5%)", "38 (28.6%)", - "2 (1.5%)", "1 (0.8%)", "", "36", "3 (2.3%)", "28 (21.2%)", "5 (3.8%)", - "0", "Missing", "", "2", "0", "1 (0.8%)", "0", "1 (0.8%)", "", - "2", "0", "2 (1.5%)", "0", "0", "", "1", "1 (0.8%)", "0", "0", + "0", "0", "0", "", "0", "0", "0", "0", "0", "NORMAL", "", "95", + "2 (1.5%)", "88 (65.7%)", "5 (3.7%)", "0", "", "88", "8 (6%)", + "76 (56.7%)", "3 (2.2%)", "1 (0.7%)", "", "96", "12 (9.1%)", + "79 (59.8%)", "5 (3.8%)", "0", "HIGH", "", "37", "4 (3%)", + "31 (23.1%)", "1 (0.7%)", "1 (0.7%)", "", "44", "2 (1.5%)", "39 (29.1%)", + "2 (1.5%)", "1 (0.7%)", "", "35", "3 (2.3%)", "27 (20.5%)", "4 (3%)", + "1 (0.8%)", "Missing", "", "2", "0", "1 (0.7%)", "0", "1 (0.7%)", "", + "2", "0", "2 (1.5%)", "0", "0", "", "1", "0", "0", "1 (0.8%)", "0" ), .Dim = c(19L, 5L) diff --git a/tests/testthat/test-table_egt04.R b/tests/testthat/test-table_egt04.R index b1e7f4ff5c..ddfd8e39cf 100644 --- a/tests/testthat/test-table_egt04.R +++ b/tests/testthat/test-table_egt04.R @@ -48,14 +48,14 @@ testthat::test_that("EGT04 default variant is produced correctly", { result_matrix <- to_string_matrix(result) expected_matrix <- structure( c( - "", "A: Drug X (N=133)", "Normal", "Abnormal", "Missing", - "B: Placebo (N=134)", "Normal", "Abnormal", "Missing", "C: Combination (N=130)", - "Normal", "Abnormal", "Missing", "Normal", "", "24 (18%)", "6 (4.5%)", - "0", "", "14 (10.4%)", "4 (3%)", "1 (0.7%)", "", "23 (17.7%)", - "14 (10.8%)", "1 (0.8%)", "Abnormal", "", "76 (57.1%)", "24 (18%)", - "1 (0.8%)", "", "88 (65.7%)", "24 (17.9%)", "1 (0.7%)", "", "66 (50.8%)", - "25 (19.2%)", "0", "Missing", "", "1 (0.8%)", "0", - "1 (0.8%)", "", "2 (1.5%)", "0", "0", "", "1 (0.8%)", + "", "A: Drug X (N=134)", "Normal", "Abnormal", "Missing", + "B: Placebo (N=134)", "Normal", "Abnormal", "Missing", "C: Combination (N=132)", + "Normal", "Abnormal", "Missing", "Normal", "", "20 (14.9%)", "11 (8.2%)", + "0", "", "18 (13.4%)", "3 (2.2%)", "0", "", "26 (19.7%)", + "6 (4.5%)", "1 (0.8%)", "Abnormal", "", "81 (60.4%)", "19 (14.2%)", + "1 (0.7%)", "", "81 (60.4%)", "28 (20.9%)", "2 (1.5%)", "", "69 (52.3%)", + "29 (22%)", "0", "Missing", "", "1 (0.7%)", "0", + "1 (0.7%)", "", "2 (1.5%)", "0", "0", "", "1 (0.8%)", "0", "0" ), .Dim = c(13L, 4L) diff --git a/tests/testthat/test-table_lbt08.R b/tests/testthat/test-table_lbt08.R index b7a7068d40..87419db5f4 100644 --- a/tests/testthat/test-table_lbt08.R +++ b/tests/testthat/test-table_lbt08.R @@ -41,9 +41,9 @@ testthat::test_that("LBT08 produce correctly", { "PARAMCD", " GRADDR", "ALT", "High", "1", "2", "3", "4", "Any", "Low", "1", "2", "3", "4", "Any", "CRP", "Low", "1", "2", "3", "4", "Any", "IGA", "High", "1", "2", "3", - "4", "Any", "ARM A", "(N=134)", "", "", "16/119 (13.4%)", "14/123 (11.4%)", - "9/127 (7.1%)", "12/129 (9.3%)", "51/129 (39.5%)", "", "13/124 (10.5%)", - "13/127 (10.2%)", "19/128 (14.8%)", "7/130 (5.4%)", "52/130 (40%)", + "4", "Any", "ARM A", "(N=134)", "", "", "16/121 (13.2%)", "14/125 (11.2%)", + "9/129 (7%)", "12/131 (9.2%)", "51/131 (38.9%)", "", "13/124 (10.5%)", + "13/127 (10.2%)", "19/129 (14.7%)", "7/131 (5.3%)", "52/131 (39.7%)", "", "", "14/122 (11.5%)", "21/124 (16.9%)", "12/129 (9.3%)", "10/131 (7.6%)", "57/131 (43.5%)", "", "", "24/118 (20.3%)", "13/120 (10.8%)", "11/124 (8.9%)", "11/129 (8.5%)", "59/129 (45.7%)", @@ -53,10 +53,10 @@ testthat::test_that("LBT08 produce correctly", { "", "", "17/125 (13.6%)", "12/130 (9.2%)", "9/131 (6.9%)", "7/133 (5.3%)", "45/133 (33.8%)", "", "", "12/120 (10%)", "19/124 (15.3%)", "10/128 (7.8%)", "13/130 (10%)", "54/130 (41.5%)", "ARM C", "(N=132)", "", "", - "17/116 (14.7%)", "17/119 (14.3%)", "13/123 (10.6%)", "13/128 (10.2%)", - "60/128 (46.9%)", "", "9/116 (7.8%)", "11/123 (8.9%)", "10/127 (7.9%)", - "10/131 (7.6%)", "40/131 (30.5%)", "", "", "13/117 (11.1%)", - "16/122 (13.1%)", "16/123 (13%)", "4/124 (3.2%)", "49/124 (39.5%)", + "17/117 (14.5%)", "17/120 (14.2%)", "13/124 (10.5%)", "13/129 (10.1%)", + "60/129 (46.5%)", "", "9/117 (7.7%)", "11/124 (8.9%)", "10/128 (7.8%)", + "10/132 (7.6%)", "40/132 (30.3%)", "", "", "13/120 (10.8%)", + "16/125 (12.8%)", "17/126 (13.5%)", "4/127 (3.1%)", "50/127 (39.4%)", "", "", "13/119 (10.9%)", "13/125 (10.4%)", "17/128 (13.3%)", "4/130 (3.1%)", "47/130 (36.2%)" ), diff --git a/tests/testthat/test-table_mht01.R b/tests/testthat/test-table_mht01.R index 58f457424f..ba7a312e32 100644 --- a/tests/testthat/test-table_mht01.R +++ b/tests/testthat/test-table_mht01.R @@ -107,17 +107,12 @@ testthat::test_that("MHT01 variant 2 is produced accurately", { expected_matrix <- structure(c( "", "", "Total number of patients with at least one event", - "Total number of events", "cl B", "Total number of patients with at least one event", - "Total number of events", "trm B_1/3", "trm B_3/3", "cl D", "Total number of patients with at least one event", - "Total number of events", "trm D_1/3", "trm D_2/3", "A: Drug X", - "(N=134)", "2 (1.5%)", "3", "", "2 (1.5%)", "2", "1 (0.7%)", - "1 (0.7%)", "", "1 (0.7%)", "1", "0", "1 (0.7%)", "B: Placebo", - "(N=134)", "0", "0", "", "0", "0", "0", "0", - "", "0", "0", "0", "0", "C: Combination", "(N=132)", - "2 (1.5%)", "2", "", "0", "0", "0", "0", "", "2 (1.5%)", - "2", "1 (0.8%)", "1 (0.8%)" + "Total number of events", "cl D", "Total number of patients with at least one event", + "Total number of events", "trm D_2/3", "A: Drug X", "(N=134)", "0", "0", "", "0", "0", "0", + "B: Placebo", "(N=134)", "0", "0", "", "0", "0", "0", + "C: Combination", "(N=132)", "1 (0.8%)", "1", "", "1 (0.8%)", "1", "1 (0.8%)" ), - .Dim = c(14L, 4L) + .Dim = c(8L, 4L) ) testthat::expect_identical(result_matrix, expected_matrix) diff --git a/tests/testthat/test-table_pkpc01.R b/tests/testthat/test-table_pkpc01.R index 5d681c3e0e..d692153631 100644 --- a/tests/testthat/test-table_pkpc01.R +++ b/tests/testthat/test-table_pkpc01.R @@ -15,16 +15,19 @@ testthat::test_that("PKCT01 is produced correctly", { result_matrix <- to_string_matrix(result) expected_matrix <- structure( c( - "", "A: Drug X", "Plasma Drug X", "Plasma Drug Y", "C: Combination", "Plasma Drug X", - "Plasma Drug Y", "n", "", "1474", "0", "", "1452", "1452", "Mean", "", "6.5", "NA", "", - "6.5", "13.1", "SD", "", "6.7", "NA", "", "6.7", "13.5", "SE", "", "0.2", "NA", "", - "0.2", "0.4", "CV (%)", "", "102.4", "NA", "", "103.3", "103.3", "CV % Geometric Mean", - "", "NA", "NA", "", "NA", "NA" + "", "A: Drug X", "Plasma Drug X", "Plasma Drug Y", "Urine Drug X", "Urine Drug Y", + "C: Combination", "Plasma Drug X", "Plasma Drug Y", "Urine Drug X", "Urine Drug Y", + "n", "", "1474", "0", "804", "804", "", "1452", "1452", "792", "792", + "Mean", "", "6.5", "NA", "0.9", "0.9", "", "6.5", "13.1", "0.8", "0.8", + "SD", "", "6.7", "NA", "1.8", "1.8", "", "6.7", "13.5", "1.8", "1.8", + "SE", "", "0.2", "NA", "0.1", "0.1", "", "0.2", "0.4", "0.1", "0.1", + "CV (%)", "", "102.4", "NA", "210.7", "210.7", "", "103.3", "103.3", "212.4", "212.4", + "CV % Geometric Mean", "", "NA", "NA", "NA", "NA", "", "NA", "NA", "NA", "NA" ), - .Dim = c(7L, 7L) + .Dim = c(11L, 7L) ) - testthat::expect_identical(result_matrix, expected_matrix) + testthat::expect_identical(result_matrix, expected_matrix) l2 <- basic_table() %>% split_rows_by( @@ -43,11 +46,12 @@ testthat::test_that("PKCT01 is produced correctly", { result_matrix <- to_string_matrix(result) expected_matrix <- structure( c( - "", "A: Drug X", "Plasma Drug X", "Plasma Drug Y", - "C: Combination", "Plasma Drug X", "Plasma Drug Y", - "n_blq", "", "402", "0", "", "396", "396" + "", "A: Drug X", "Plasma Drug X", "Plasma Drug Y", "Urine Drug X", "Urine Drug Y", + "C: Combination", "Plasma Drug X", "Plasma Drug Y", "Urine Drug X", "Urine Drug Y", + "n_blq", "", "402", "0", "402", "402", "", "396", "396", "396", "396" ), - .Dim = c(7L, 2L) + .Dim = c(11L, 2L) ) + testthat::expect_identical(result_matrix, expected_matrix) }) diff --git a/tests/testthat/test-table_pkpt02_04_06.R b/tests/testthat/test-table_pkpt02_04_06.R index bb0f962022..1ed4fb960d 100644 --- a/tests/testthat/test-table_pkpt02_04_06.R +++ b/tests/testthat/test-table_pkpt02_04_06.R @@ -15,7 +15,7 @@ l <- basic_table() %>% split_cols_by( var = "ARMCD", split_fun = trim_levels_in_group("ARMCD"), - # label_pos = "topleft", + # label_pos = "topleft", # nolint split_label = "Treatment Arm" ) %>% split_rows_by( @@ -54,16 +54,16 @@ testthat::test_that("PKPT02 is produced correctly for Drug X", { "CL obs (ml/day/kg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "Cmax (ug/mL)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", - "Min - Max", "ARM A", "", "134", "2.042e+02 (3.925e+01)", "19.2", - "2.002e+02", "20.6", "2.072e+02", "1.095e+02 - 3.017e+02", "", "134", - "5.025e+00 (9.394e-01)", "18.7", "4.934e+00", "19.8", "5.082e+00", - "3.144e+00 - 7.218e+00", "", "134", "2.975e+01 (5.758e+00)", "19.4", - "2.918e+01", "20.1", "2.941e+01", "1.561e+01 - 4.600e+01", "ARM C", "", - "132", "1.999e+02 (4.169e+01)", "20.9", "1.950e+02", "23.6", "2.050e+02", - "7.412e+01 - 2.778e+02", "", "132", "5.221e+00 (1.015e+00)", "19.4", - "5.118e+00", "20.6", "5.202e+00", "2.513e+00 - 7.912e+00", "", "132", - "2.948e+01 (6.405e+00)", "21.7", "2.868e+01", "25.1", "3.014e+01", - "9.297e+00 - 4.324e+01" + "Min - Max", "ARM A", "", "134", "2.028e+02 (3.766e+01)", "18.6", + "1.994e+02", "18.7", "1.971e+02", "1.253e+02 - 3.110e+02", "", "134", + "5.043e+00 (1.041e+00)", "20.6", "4.929e+00", "22.4", "5.078e+00", + "2.255e+00 - 7.395e+00", "", "134", "3.025e+01 (6.239e+00)", "20.6", + "2.961e+01", "21.0", "2.986e+01", "1.753e+01 - 4.871e+01", "ARM C", "", + "132", "1.955e+02 (3.785e+01)", "19.4", "1.917e+02", "20.1", "1.962e+02", + "1.030e+02 - 3.145e+02", "", "132", "5.009e+00 (9.846e-01)", "19.7", + "4.907e+00", "21.1", "4.969e+00", "2.102e+00 - 7.489e+00", "", "132", + "3.004e+01 (5.457e+00)", "18.2", "2.954e+01", "18.9", "2.977e+01", + "1.585e+01 - 4.757e+01" ), .Dim = c(25L, 3L) ) @@ -87,11 +87,11 @@ testthat::test_that("PKPT02 is produced correctly for Drug Y", { "CL obs (ml/day/kg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "Cmax (ug/mL)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", - "Median", "Min - Max", "ARM C", "", "132", "1.953e+02 (3.828e+01)", - "19.6", "1.916e+02", "20.0", "1.960e+02", "1.110e+02 - 3.182e+02", "", - "132", "4.968e+00 (9.921e-01)", "20.0", "4.864e+00", "21.3", "4.970e+00", - "2.261e+00 - 7.958e+00", "", "132", "2.945e+01 (5.762e+00)", "19.6", - "2.888e+01", "20.3", "2.872e+01", "1.455e+01 - 4.856e+01" + "Median", "Min - Max", "ARM C", "", "132", "1.986e+02 (3.792e+01)", + "19.1", "1.952e+02", "18.9", "1.953e+02", "1.264e+02 - 3.183e+02", "", + "132", "4.955e+00 (8.951e-01)", "18.1", "4.873e+00", "18.7", "4.936e+00", + "2.987e+00 - 7.211e+00", "", "132", "2.990e+01 (5.550e+00)", "18.6", + "2.935e+01", "20.1", "2.969e+01", "1.406e+01 - 4.345e+01" ), .Dim = c(25L, 2L) ) @@ -116,19 +116,19 @@ testthat::test_that("PKPT04 is produced correctly for Drug X", { "Min - Max", "Fe (%)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "RENALCLD (L/hr/mg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", - "Min - Max", "ARM A", "", "268", "1.539e+00 (2.988e-01)", "19.4", - "1.508e+00", "20.8", "1.518e+00", "6.223e-01 - 2.328e+00", "", "134", - "5.010e-02 (1.026e-02)", "20.5", "4.897e-02", "22.3", "4.935e-02", - "2.370e-02 - 7.332e-02", "", "268", "1.591e+01 (2.990e+00)", "18.8", - "1.562e+01", "19.8", "1.592e+01", "7.714e+00 - 2.379e+01", "", "134", - "5.009e-03 (1.009e-03)", "20.1", "4.905e-03", "21.1", "4.909e-03", - "2.426e-03 - 7.670e-03", "ARM C", "", "264", "1.593e+00 (3.043e-01)", - "19.1", "1.563e+00", "19.8", "1.575e+00", "8.536e-01 - 2.419e+00", "", - "132", "4.959e-02 (1.031e-02)", "20.8", "4.854e-02", "21.0", "4.906e-02", - "3.149e-02 - 8.150e-02", "", "264", "1.562e+01 (2.909e+00)", "18.6", - "1.534e+01", "19.6", "1.557e+01", "7.197e+00 - 2.294e+01", "", "132", - "4.963e-03 (1.006e-03)", "20.3", "4.859e-03", "21.2", "4.980e-03", - "2.344e-03 - 7.306e-03" + "Min - Max", "ARM A", "", "268", "1.551e+00 (3.385e-01)", "21.8", + "1.513e+00", "23.0", "1.547e+00", "7.021e-01 - 2.464e+00", "", "134", + "4.918e-02 (9.611e-03)", "19.5", "4.818e-02", "21.0", "4.909e-02", + "2.488e-02 - 7.511e-02", "", "268", "1.571e+01 (3.348e+00)", "21.3", + "1.534e+01", "22.2", "1.577e+01", "8.147e+00 - 2.452e+01", "", "134", + "4.873e-03 (9.654e-04)", "19.8", "4.772e-03", "21.2", "4.967e-03", + "2.385e-03 - 7.258e-03", "ARM C", "", "264", "1.535e+00 (2.978e-01)", + "19.4", "1.505e+00", "20.3", "1.547e+00", "8.502e-01 - 2.208e+00", "", + "132", "5.024e-02 (1.050e-02)", "20.9", "4.913e-02", "21.9", "4.984e-02", + "2.505e-02 - 8.560e-02", "", "264", "1.609e+01 (3.103e+00)", "19.3", + "1.578e+01", "20.2", "1.604e+01", "8.503e+00 - 2.443e+01", "", "132", + "5.110e-03 (9.339e-04)", "18.3", "5.019e-03", "19.7", "5.151e-03", + "2.356e-03 - 7.407e-03" ), .Dim = c(33L, 3L) ) @@ -154,12 +154,12 @@ testthat::test_that("PKPT04 is produced correctly for Drug Y", { "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "RENALCLD (L/hr/mg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "ARM C", "", "264", - "1.587e+00 (2.881e-01)", "18.2", "1.559e+00", "19.4", "1.593e+00", - "7.698e-01 - 2.152e+00", "", "132", "5.056e-02 (1.011e-02)", "20.0", - "4.950e-02", "21.4", "5.101e-02", "2.226e-02 - 7.606e-02", "", "264", - "1.552e+01 (2.932e+00)", "18.9", "1.524e+01", "19.7", "1.550e+01", - "8.133e+00 - 2.639e+01", "", "132", "5.124e-03 (9.578e-04)", "18.7", - "5.029e-03", "20.0", "5.175e-03", "2.676e-03 - 7.541e-03" + "1.598e+00 (3.154e-01)", "19.7", "1.565e+00", "21.4", "1.603e+00", + "8.574e-01 - 2.257e+00", "", "132", "4.966e-02 (1.009e-02)", "20.3", + "4.857e-02", "22.0", "4.912e-02", "1.839e-02 - 7.761e-02", "", "264", + "1.583e+01 (3.077e+00)", "19.4", "1.552e+01", "20.2", "1.570e+01", + "8.311e+00 - 2.378e+01", "", "132", "5.093e-03 (1.032e-03)", "20.3", + "4.985e-03", "21.4", "5.017e-03", "2.356e-03 - 7.939e-03" ), .Dim = c(33L, 2L) ) @@ -180,10 +180,10 @@ testthat::test_that("PKPT06 is produced correctly for Drug X", { c( "PK Parameter", "RENALCLD (L/hr/mg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "ARM A", - "", "134", "5.009e-03 (1.009e-03)", "20.1", "4.905e-03", "21.1", - "4.909e-03", "2.426e-03 - 7.670e-03", "ARM C", "", "132", - "4.963e-03 (1.006e-03)", "20.3", "4.859e-03", "21.2", "4.980e-03", - "2.344e-03 - 7.306e-03" + "", "134", "4.873e-03 (9.654e-04)", "19.8", "4.772e-03", "21.2", + "4.967e-03", "2.385e-03 - 7.258e-03", "ARM C", "", "132", + "5.110e-03 (9.339e-04)", "18.3", "5.019e-03", "19.7", "5.151e-03", + "2.356e-03 - 7.407e-03" ), .Dim = c(9L, 3L) ) @@ -204,8 +204,8 @@ testthat::test_that("PKPT06 is produced correctly for Drug Y", { c( "PK Parameter", "RENALCLD (L/hr/mg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "ARM C", - "", "132", "5.124e-03 (9.578e-04)", "18.7", "5.029e-03", "20.0", - "5.175e-03", "2.676e-03 - 7.541e-03" + "", "132", "5.093e-03 (1.032e-03)", "20.3", "4.985e-03", "21.4", + "5.017e-03", "2.356e-03 - 7.939e-03" ), .Dim = c(9L, 2L) ) diff --git a/tests/testthat/test-table_pkpt03_05_07.R b/tests/testthat/test-table_pkpt03_05_07.R index 140aad2317..b94266e474 100644 --- a/tests/testthat/test-table_pkpt03_05_07.R +++ b/tests/testthat/test-table_pkpt03_05_07.R @@ -67,22 +67,21 @@ testthat::test_that("PKPT03 Drug X is produced correctly", { main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population") subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT)) - result_matrix <- to_string_matrix(result) expected_matrix <- c( "Treatment Arm", "", "", "", "", "", "", "", "", "", " PK Parameter", "n", "Mean", "SD", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Minimum", "Maximum", "ARM A", "", "", "", "", "", "", "", "", "", - "AUCinf obs (day*ug/mL)", "134", "2.042e+02", "3.925e+01", "19.2", "2.002e+02", "20.6", - "2.072e+02", "1.095e+02", "3.017e+02", "CL obs (ml/day/kg)", "134", "5.025e+00", - "9.394e-01", "18.7", "4.934e+00", "19.8", "5.082e+00", "3.144e+00", "7.218e+00", - "Cmax (ug/mL)", "134", "2.975e+01", "5.758e+00", "19.4", "2.918e+01", "20.1", - "2.941e+01", "1.561e+01", "4.600e+01", "ARM C", "", "", "", "", "", "", "", "", "", - "AUCinf obs (day*ug/mL)", "132", "1.999e+02", "4.169e+01", "20.9", "1.950e+02", - "23.6", "2.050e+02", "7.412e+01", "2.778e+02", "CL obs (ml/day/kg)", "132", - "5.221e+00", "1.015e+00", "19.4", "5.118e+00", "20.6", "5.202e+00", "2.513e+00", - "7.912e+00", "Cmax (ug/mL)", "132", "2.948e+01", "6.405e+00", "21.7", "2.868e+01", - "25.1", "3.014e+01", "9.297e+00", "4.324e+01" + "AUCinf obs (day*ug/mL)", "134", "2.028e+02", "3.766e+01", "18.6", "1.994e+02", "18.7", + "1.971e+02", "1.253e+02", "3.110e+02", "CL obs (ml/day/kg)", "134", "5.043e+00", + "1.041e+00", "20.6", "4.929e+00", "22.4", "5.078e+00", "2.255e+00", "7.395e+00", + "Cmax (ug/mL)", "134", "3.025e+01", "6.239e+00", "20.6", "2.961e+01", "21.0", + "2.986e+01", "1.753e+01", "4.871e+01", "ARM C", "", "", "", "", "", "", "", "", "", + "AUCinf obs (day*ug/mL)", "132", "1.955e+02", "3.785e+01", "19.4", "1.917e+02", + "20.1", "1.962e+02", "1.030e+02", "3.145e+02", "CL obs (ml/day/kg)", "132", + "5.009e+00", "9.846e-01", "19.7", "4.907e+00", "21.1", "4.969e+00", "2.102e+00", + "7.489e+00", "Cmax (ug/mL)", "132", "3.004e+01", "5.457e+00", "18.2", "2.954e+01", + "18.9", "2.977e+01", "1.585e+01", "4.757e+01" ) expected_matrix <- matrix(expected_matrix, nrow = 10, ncol = 10, byrow = TRUE) @@ -103,16 +102,15 @@ testthat::test_that("PKPT03 Drug Y is produced correctly", { "Treatment Arm", "", "", "", "", "", "", "", "", "", " PK Parameter", "n", "Mean", "SD", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Minimum", "Maximum", "ARM C", "", "", "", "", "", "", "", "", "", "AUCinf obs (day*ug/mL)", - "132", "1.953e+02", "3.828e+01", "19.6", "1.916e+02", "20.0", "1.960e+02", "1.110e+02", - "3.182e+02", "CL obs (ml/day/kg)", "132", "4.968e+00", "9.921e-01", "20.0", "4.864e+00", - "21.3", "4.970e+00", "2.261e+00", "7.958e+00", "Cmax (ug/mL)", "132", "2.945e+01", - "5.762e+00", "19.6", "2.888e+01", "20.3", "2.872e+01", "1.455e+01", "4.856e+01" + "132", "1.986e+02", "3.792e+01", "19.1", "1.952e+02", "18.9", "1.953e+02", "1.264e+02", + "3.183e+02", "CL obs (ml/day/kg)", "132", "4.955e+00", "8.951e-01", "18.1", "4.873e+00", + "18.7", "4.936e+00", "2.987e+00", "7.211e+00", "Cmax (ug/mL)", "132", "2.990e+01", + "5.550e+00", "18.6", "2.935e+01", "20.1", "2.969e+01", "1.406e+01", "4.345e+01" ) expected_matrix <- matrix(expected_matrix, nrow = 6, ncol = 10, byrow = TRUE) testthat::expect_identical(result_matrix, expected_matrix) }) - # PKPT05 Drug X testthat::test_that("PKPT05 Drug X is produced correctly", { adpp0 <- adpp_urine %>% @@ -127,21 +125,18 @@ testthat::test_that("PKPT05 Drug X is produced correctly", { expected_matrix <- c( "Treatment Arm", "", "", "", "", "", "", "", "", "", - " PK Parameter", "n", "Mean", "SD", "CV (%)", "Geometric Mean", "CV % Geometric Mean", - "Median", "Minimum", "Maximum", "ARM A", "", "", "", "", "", "", "", "", "", - "Ae (mg)", "268", "1.539e+00", "2.988e-01", "19.4", "1.508e+00", "20.8", - "1.518e+00", "6.223e-01", "2.328e+00", "CLR (L/hr)", "134", "5.010e-02", - "1.026e-02", "20.5", "4.897e-02", "22.3", "4.935e-02", "2.370e-02", - "7.332e-02", "Fe (%)", "268", "1.591e+01", "2.990e+00", "18.8", "1.562e+01", - "19.8", "1.592e+01", "7.714e+00", "2.379e+01", "RENALCLD (L/hr/mg)", "134", - "5.009e-03", "1.009e-03", "20.1", "4.905e-03", "21.1", "4.909e-03", - "2.426e-03", "7.670e-03", "ARM C", "", "", "", "", "", "", "", "", "", - "Ae (mg)", "264", "1.593e+00", "3.043e-01", "19.1", "1.563e+00", "19.8", - "1.575e+00", "8.536e-01", "2.419e+00", "CLR (L/hr)", "132", "4.959e-02", - "1.031e-02", "20.8", "4.854e-02", "21.0", "4.906e-02", "3.149e-02", "8.150e-02", - "Fe (%)", "264", "1.562e+01", "2.909e+00", "18.6", "1.534e+01", "19.6", "1.557e+01", - "7.197e+00", "2.294e+01", "RENALCLD (L/hr/mg)", "132", "4.963e-03", "1.006e-03", - "20.3", "4.859e-03", "21.2", "4.980e-03", "2.344e-03", "7.306e-03" + " PK Parameter", "n", "Mean", "SD", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", + "Minimum", "Maximum", "ARM A", "", "", "", "", "", "", "", "", "", + "Ae (mg)", "268", "1.551e+00", "3.385e-01", "21.8", "1.513e+00", "23.0", "1.547e+00", "7.021e-01", "2.464e+00", + "CLR (L/hr)", "134", "4.918e-02", "9.611e-03", "19.5", "4.818e-02", "21.0", "4.909e-02", "2.488e-02", "7.511e-02", + "Fe (%)", "268", "1.571e+01", "3.348e+00", "21.3", "1.534e+01", "22.2", "1.577e+01", "8.147e+00", "2.452e+01", + "RENALCLD (L/hr/mg)", "134", "4.873e-03", "9.654e-04", "19.8", "4.772e-03", "21.2", "4.967e-03", + "2.385e-03", "7.258e-03", "ARM C", "", "", "", "", "", "", "", "", "", + "Ae (mg)", "264", "1.535e+00", "2.978e-01", "19.4", "1.505e+00", "20.3", "1.547e+00", "8.502e-01", "2.208e+00", + "CLR (L/hr)", "132", "5.024e-02", "1.050e-02", "20.9", "4.913e-02", "21.9", "4.984e-02", "2.505e-02", "8.560e-02", + "Fe (%)", "264", "1.609e+01", "3.103e+00", "19.3", "1.578e+01", "20.2", "1.604e+01", "8.503e+00", "2.443e+01", + "RENALCLD (L/hr/mg)", "132", "5.110e-03", "9.339e-04", "18.3", "5.019e-03", "19.7", "5.151e-03", "2.356e-03", + "7.407e-03" ) expected_matrix <- matrix(expected_matrix, nrow = 12, ncol = 10, byrow = TRUE) @@ -166,19 +161,17 @@ testthat::test_that("PKPT05 Drug Y is produced correctly", { " PK Parameter", "n", "Mean", "SD", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Minimum", "Maximum", "ARM C", "", "", "", "", "", "", "", "", "", - "Ae (mg)", "264", "1.587e+00", "2.881e-01", "18.2", "1.559e+00", - "19.4", "1.593e+00", "7.698e-01", "2.152e+00", "CLR (L/hr)", "132", - "5.056e-02", "1.011e-02", "20.0", "4.950e-02", "21.4", "5.101e-02", - "2.226e-02", "7.606e-02", "Fe (%)", "264", "1.552e+01", "2.932e+00", "18.9", - "1.524e+01", "19.7", "1.550e+01", "8.133e+00", "2.639e+01", "RENALCLD (L/hr/mg)", - "132", "5.124e-03", "9.578e-04", "18.7", "5.029e-03", "20.0", "5.175e-03", "2.676e-03", "7.541e-03" # nolint + "Ae (mg)", "264", "1.598e+00", "3.154e-01", "19.7", "1.565e+00", "21.4", "1.603e+00", "8.574e-01", "2.257e+00", + "CLR (L/hr)", "132", "4.966e-02", "1.009e-02", "20.3", "4.857e-02", "22.0", "4.912e-02", "1.839e-02", "7.761e-02", + "Fe (%)", "264", "1.583e+01", "3.077e+00", "19.4", "1.552e+01", "20.2", "1.570e+01", "8.311e+00", "2.378e+01", + "RENALCLD (L/hr/mg)", "132", "5.093e-03", "1.032e-03", "20.3", "4.985e-03", "21.4", "5.017e-03", "2.356e-03", + "7.939e-03" ) expected_matrix <- matrix(expected_matrix, nrow = 7, ncol = 10, byrow = TRUE) testthat::expect_identical(result_matrix, expected_matrix) }) - # PKPT07 Drug X testthat::test_that("PKPT07 Drug X is produced correctly", { # Plasma Drug X__ @@ -196,17 +189,15 @@ testthat::test_that("PKPT07 Drug X is produced correctly", { "Treatment Arm", "", "", "", "", "", "", "", "", "", " PK Parameter", "n", "Mean", "SD", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Minimum", "Maximum", "ARM A", "", "", "", "", "", "", "", "", "", - "RENALCLD (L/hr/mg)", "134", "5.009e-03", "1.009e-03", "20.1", "4.905e-03", "21.1", - "4.909e-03", "2.426e-03", "7.670e-03", "ARM C", "", "", "", "", "", "", "", "", "", - "RENALCLD (L/hr/mg)", "132", "4.963e-03", "1.006e-03", "20.3", "4.859e-03", - "21.2", "4.980e-03", "2.344e-03", "7.306e-03" + "RENALCLD (L/hr/mg)", "134", "4.873e-03", "9.654e-04", "19.8", "4.772e-03", "21.2", "4.967e-03", "2.385e-03", + "7.258e-03", "ARM C", "", "", "", "", "", "", "", "", "", "RENALCLD (L/hr/mg)", "132", "5.110e-03", "9.339e-04", + "18.3", "5.019e-03", "19.7", "5.151e-03", "2.356e-03", "7.407e-03" ) expected_matrix <- matrix(expected_matrix, nrow = 6, ncol = 10, byrow = TRUE) testthat::expect_identical(result_matrix, expected_matrix) }) - # PKPT07 Drug Y testthat::test_that("PKPT07 Drug Y is produced correctly", { # Plasma Drug Y @@ -224,8 +215,8 @@ testthat::test_that("PKPT07 Drug Y is produced correctly", { "Treatment Arm", "", "", "", "", "", "", "", "", "", " PK Parameter", "n", "Mean", "SD", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", "Minimum", "Maximum", "ARM C", - "", "", "", "", "", "", "", "", "", "RENALCLD (L/hr/mg)", "132", "5.124e-03", - "9.578e-04", "18.7", "5.029e-03", "20.0", "5.175e-03", "2.676e-03", "7.541e-03" + "", "", "", "", "", "", "", "", "", "RENALCLD (L/hr/mg)", "132", "5.093e-03", + "1.032e-03", "20.3", "4.985e-03", "21.4", "5.017e-03", "2.356e-03", "7.939e-03" ) expected_matrix <- matrix(expected_matrix, nrow = 4, ncol = 10, byrow = TRUE)