From e57dac68feee70b7c2c75a7e0e418c752323dcd6 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Tue, 29 Aug 2023 18:02:14 -0400 Subject: [PATCH 01/12] init --- book/tables/pharmacokinetic/pkct01.qmd | 220 +++++++++++++++--- .../testthat/_snaps/pkct01/markdown-snaps.md | 110 +++++++-- 2 files changed, 271 insertions(+), 59 deletions(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index ce9e60fce..236b0008e 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -27,17 +27,14 @@ adpc_1 <- adpc %>% ) %>% filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X") %>% mutate(ACTARM = factor(ACTARM, levels = c("A: Drug X"))) %>% - select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) + select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>% + var_relabel(NFRLT = "Nominal Time from First Dose (hr)") # Helper function -threesigfmt <- function(x, ...) { +three_sig_fmt <- function(x, ...) { as.character(signif(x, 3)) } -``` - -## Standard Table (Stats in Columns) -```{r variant1, test = list(result_v1 = "result")} # Row structure l_rows <- basic_table() %>% split_rows_by( @@ -52,52 +49,199 @@ l_rows <- basic_table() %>% ) %>% split_rows_by( var = "NFRLT", - split_label = "Norminal Time from First Dose", + split_fun = drop_split_levels, + split_label = obj_label(adpc_1$NFRLT), label_pos = "topleft", child_labels = "hidden" ) +``` + +```{r} +summary_stats_imp <- function(df, stat, imp, post = FALSE) { + n_blq <- sum(df$AVALCAT1 %in% c("BLQ", "LTR", " 0) + na_level <- if (stat %in% c("mean", "min", "sd", "cv_mean", "cv_geomean")) "ND" else "NE" + } else if (imp_rule == "1/2") { + res <- summary_stats_imp(.df_row, stat, imp = 1 / 2, post = FALSE) + na_level <- "ND" + } + + if (is.list(res)) { + if (length(res) > 1) { + stop("The analyzed column produced more than one category of results.") + } else { + res <- unlist(res) + } + } + + rcell( + res, + label = .spl_context$value[nrow(.spl_context)], + format = .formats[names(.formats) == stat][[1]], + format_na_str = na_level, + indent_mod = ifelse(is.null(.indent_mods), 0L, .indent_mods), + align = .aligns + ) + } + }, + stat = .stats + ) + + analyze_colvars( + lyt, + afun = afun_list, + nested = TRUE, + extra_args = list(...) + ) +} +``` + +## Standard Table (Stats in Columns) + +```{r variant1, test = list(result_v1 = "result")} +lyt <- l_rows %>% + analyze_pk_vars_in_cols( + vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)) + ) + +result <- build_table(lyt, df = adpc_1) %>% prune_table() +# Decorating +main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" +subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM))) +main_footer(result) <- "NE: Not Estimable" + +result +``` + +## Table Implementing 1/3 Imputation Rule + +```{r variant2, test = list(result_v2 = "result")} # Column results for numeric values lyt <- l_rows %>% - analyze_vars_in_cols( + analyze_pk_vars_in_cols( + vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), + imp_rule = "1/3" + ) + +result <- build_table(lyt, df = adpc_1) %>% prune_table() + +# Decorating +main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" +subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM))) +main_footer(result) <- "NE: Not Estimable" + +result +``` + +## Table Implementing 1/2 Imputation Rule + +```{r variant3, test = list(result_v3 = "result")} +lyt <- l_rows %>% + analyze_pk_vars_in_cols( vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), - .stats = c( - "n", "n_blq", "mean", "sd", "cv", - "geom_mean", "geom_cv", # "geom_mean_ci", - "median", "min", "max" - ), - .formats = c( - n = "xx.", - n_blq = "xx.", - mean = threesigfmt, - sd = threesigfmt, - cv = "xx.x", - median = threesigfmt, - geom_mean = threesigfmt, - geom_cv = "xx.x", - min = threesigfmt, - max = threesigfmt - ), - .labels = c( - n = "n", - n_blq = "Number\nof\nLTRs/BLQs", - mean = "Mean", - sd = "SD", - cv = "CV (%) Mean", - geom_mean = "Geometric Mean", - geom_cv = "CV % Geometric Mean", - median = "Median", - min = "Minimum", - max = "Maximum" - ), - na_level = "NE" + imp_rule = "1/2" ) + result <- build_table(lyt, df = adpc_1) %>% prune_table() # Decorating main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM))) main_footer(result) <- "NE: Not Estimable" + result ``` diff --git a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md index 64bdb0d3a..db9d9b25a 100644 --- a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md +++ b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md @@ -8,27 +8,95 @@ Analyte: Plasma Drug X Treatment: A: Drug X - ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Cohort/Treatment - Visit - Norminal Time from First Dose Number - of - n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum - ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X - Day 1 - 0 134 134 0 0 NE NE NE 0 0 0 - 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 - 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 - 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 - 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 - 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 - 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 - 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 - 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 - Day 2 - 24 134 134 0 0 NE NE NE 0 0 0 - ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Cohort/Treatment + Visit + Nominal Time from First Dose (hr) Number + of + n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X + Day 1 + 0 134 134 0 0 NE NE NE 0 0 0 + 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 + 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 + 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 + 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 + 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 + Day 2 + 24 134 134 0 0 NE NE NE 0 0 0 + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + + NE: Not Estimable + +# result_v2 + + Code + print(data_snap[[i]]) + Output + Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable + Protocol: xxxxx + Analyte: Plasma Drug X + Treatment: A: Drug X + + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Cohort/Treatment + Visit + Nominal Time from First Dose (hr) Number + of + n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X + Day 1 + 0 134 134 ND ND NE NE NE 0 ND 0 + 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 + 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 + 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 + 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 + 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 + Day 2 + 24 134 134 ND ND NE NE NE 0 ND 0 + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + + NE: Not Estimable + +# result_v3 + + Code + print(data_snap[[i]]) + Output + Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable + Protocol: xxxxx + Analyte: Plasma Drug X + Treatment: A: Drug X + + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Cohort/Treatment + Visit + Nominal Time from First Dose (hr) Number + of + n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X + Day 1 + 0 134 134 ND ND ND ND ND ND ND 0 + 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 + 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 + 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 + 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 + 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 + Day 2 + 24 134 134 ND ND ND ND ND ND ND 0 + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable From 21cc1ec14113250484ee27068332fe8cdc043e26 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Wed, 30 Aug 2023 16:54:22 -0400 Subject: [PATCH 02/12] Clean up funs, logic --- book/tables/pharmacokinetic/pkct01.qmd | 90 +++++++++---------- .../testthat/_snaps/pkct01/markdown-snaps.md | 29 +++--- 2 files changed, 55 insertions(+), 64 deletions(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index 236b0008e..f4596c159 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -26,7 +26,6 @@ adpc_1 <- adpc %>% AVALCAT1 = as.factor(AVALCAT1) ) %>% filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X") %>% - mutate(ACTARM = factor(ACTARM, levels = c("A: Drug X"))) %>% select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>% var_relabel(NFRLT = "Nominal Time from First Dose (hr)") @@ -36,14 +35,16 @@ three_sig_fmt <- function(x, ...) { } # Row structure -l_rows <- basic_table() %>% +lyt_rows <- basic_table() %>% split_rows_by( var = "ACTARM", - split_label = "Cohort/Treatment", + split_fun = drop_split_levels, + split_label = "Treatment Group", label_pos = "topleft" ) %>% split_rows_by( var = "VISIT", + split_fun = drop_split_levels, split_label = "Visit", label_pos = "topleft" ) %>% @@ -56,45 +57,30 @@ l_rows <- basic_table() %>% ) ``` -```{r} -summary_stats_imp <- function(df, stat, imp, post = FALSE) { +```{r helper funs} +imp_stats <- function(df, x_stats, stat, imp, post = FALSE) { n_blq <- sum(df$AVALCAT1 %in% c("BLQ", "LTR", " 0) - na_level <- if (stat %in% c("mean", "min", "sd", "cv_mean", "cv_geomean")) "ND" else "NE" - } else if (imp_rule == "1/2") { - res <- summary_stats_imp(.df_row, stat, imp = 1 / 2, post = FALSE) - na_level <- "ND" + function(u, .spl_context, .df_row, .var, cache_env = NULL, ...) { + var_row_val <- paste(.var, tail(.spl_context$value, 1), sep = "_") + if (is.null(cache_env[[var_row_val]])) cache_env[[var_row_val]] <- s_summary(u, ...) + x_stats <- cache_env[[var_row_val]] + + if (stat %in% c("n", "n_blq") | is.null(imp_rule)) { + res <- x_stats[[stat]] + } else { + imp <- if (imp_rule == "1/3") 1 / 3 else 1 / 2 + res_imp <- imp_stats(.df_row, x_stats, stat, imp = imp, post = as.numeric(tail(.spl_context$value, 1)) > 0) + res <- res_imp[["val"]] + na_level <- res_imp[["na_level"]] } if (is.list(res)) { @@ -191,7 +182,7 @@ analyze_pk_vars_in_cols <- function(lyt, ## Standard Table (Stats in Columns) ```{r variant1, test = list(result_v1 = "result")} -lyt <- l_rows %>% +lyt <- lyt_rows %>% analyze_pk_vars_in_cols( vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)) ) @@ -209,8 +200,7 @@ result ## Table Implementing 1/3 Imputation Rule ```{r variant2, test = list(result_v2 = "result")} -# Column results for numeric values -lyt <- l_rows %>% +lyt <- lyt_rows %>% analyze_pk_vars_in_cols( vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), imp_rule = "1/3" @@ -221,7 +211,7 @@ result <- build_table(lyt, df = adpc_1) %>% prune_table() # Decorating main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM))) -main_footer(result) <- "NE: Not Estimable" +main_footer(result) <- c("NE: Not Estimable", "ND: Not Derived") result ``` @@ -229,7 +219,7 @@ result ## Table Implementing 1/2 Imputation Rule ```{r variant3, test = list(result_v3 = "result")} -lyt <- l_rows %>% +lyt <- lyt_rows %>% analyze_pk_vars_in_cols( vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), imp_rule = "1/2" @@ -237,10 +227,10 @@ lyt <- l_rows %>% result <- build_table(lyt, df = adpc_1) %>% prune_table() -# Decorating +# Decorate table main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM))) -main_footer(result) <- "NE: Not Estimable" +main_footer(result) <- "ND: Not Derived" result ``` diff --git a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md index db9d9b25a..808f618d1 100644 --- a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md +++ b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md @@ -9,7 +9,7 @@ Treatment: A: Drug X ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Cohort/Treatment + Treatment Group Visit Nominal Time from First Dose (hr) Number of @@ -43,7 +43,7 @@ Treatment: A: Drug X ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Cohort/Treatment + Treatment Group Visit Nominal Time from First Dose (hr) Number of @@ -51,20 +51,21 @@ ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— A: Drug X Day 1 - 0 134 134 ND ND NE NE NE 0 ND 0 - 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 - 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 - 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 - 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 - 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 - 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 - 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 - 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 + 0 134 134 ND ND ND NE ND 0 ND 0 + 0.5 134 0 12.6 1.51 12.0 NE 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 NE 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 NE 9.3 15.5 12.3 19 + 2 134 0 13.4 1.35 10.1 NE 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 NE 15.0 8.4 5.88 10.9 + 4 134 0 4.79 1.02 21.2 NE 22.0 4.79 2.7 7.09 + 8 134 0 0.348 0.18 51.7 NE 58.4 0.318 0.076 0.866 + 12 134 0 0.0224 0.0189 84.6 NE 111.6 0.017 0.002 0.083 Day 2 - 24 134 134 ND ND NE NE NE 0 ND 0 + 24 134 134 ND ND ND NE ND 0 ND 0 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable + ND: Not Derived # result_v3 @@ -77,7 +78,7 @@ Treatment: A: Drug X ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Cohort/Treatment + Treatment Group Visit Nominal Time from First Dose (hr) Number of @@ -98,5 +99,5 @@ 24 134 134 ND ND ND ND ND ND ND 0 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - NE: Not Estimable + ND: Not Derived From 1e5048d750e43b3c472db4df9e93001ce6727b2f Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Wed, 30 Aug 2023 16:56:33 -0400 Subject: [PATCH 03/12] Update text --- book/tables/pharmacokinetic/pkct01.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index f4596c159..4e374a935 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -29,7 +29,7 @@ adpc_1 <- adpc %>% select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>% var_relabel(NFRLT = "Nominal Time from First Dose (hr)") -# Helper function +# Formatting function - 3 significant figures three_sig_fmt <- function(x, ...) { as.character(signif(x, 3)) } From 8096f8bae5f9a39b3ae77f753223ed2c0769282a Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Wed, 30 Aug 2023 19:01:23 -0400 Subject: [PATCH 04/12] Move helper funs to tern --- book/tables/pharmacokinetic/pkct01.qmd | 170 ++++-------------- .../testthat/_snaps/pkct01/markdown-snaps.md | 22 +-- 2 files changed, 48 insertions(+), 144 deletions(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index 4e374a935..9aa6e7a89 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -29,11 +29,6 @@ adpc_1 <- adpc %>% select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>% var_relabel(NFRLT = "Nominal Time from First Dose (hr)") -# Formatting function - 3 significant figures -three_sig_fmt <- function(x, ...) { - as.character(signif(x, 3)) -} - # Row structure lyt_rows <- basic_table() %>% split_rows_by( @@ -57,134 +52,23 @@ lyt_rows <- basic_table() %>% ) ``` -```{r helper funs} -imp_stats <- function(df, x_stats, stat, imp, post = FALSE) { - n_blq <- sum(df$AVALCAT1 %in% c("BLQ", "LTR", " 0) - res <- res_imp[["val"]] - na_level <- res_imp[["na_level"]] - } - - if (is.list(res)) { - if (length(res) > 1) { - stop("The analyzed column produced more than one category of results.") - } else { - res <- unlist(res) - } - } - - rcell( - res, - label = .spl_context$value[nrow(.spl_context)], - format = .formats[names(.formats) == stat][[1]], - format_na_str = na_level, - indent_mod = ifelse(is.null(.indent_mods), 0L, .indent_mods), - align = .aligns - ) - } - }, - stat = .stats - ) - - analyze_colvars( - lyt, - afun = afun_list, - nested = TRUE, - extra_args = list(...) - ) -} -``` - ## Standard Table (Stats in Columns) ```{r variant1, test = list(result_v1 = "result")} lyt <- lyt_rows %>% - analyze_pk_vars_in_cols( - vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)) + analyze_vars_in_cols( + vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), + .stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"), + .formats = c( + n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), + geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3) + ), + .labels = c( + n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", + geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" + ), + na_level = "NE", + .aligns = "decimal" ) result <- build_table(lyt, df = adpc_1) %>% prune_table() @@ -201,9 +85,19 @@ result ```{r variant2, test = list(result_v2 = "result")} lyt <- lyt_rows %>% - analyze_pk_vars_in_cols( + analyze_vars_in_cols( vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), - imp_rule = "1/3" + .stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"), + .formats = c( + n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), + geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3) + ), + .labels = c( + n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", + geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" + ), + imp_rule = "1/3", + .aligns = "decimal" ) result <- build_table(lyt, df = adpc_1) %>% prune_table() @@ -220,9 +114,19 @@ result ```{r variant3, test = list(result_v3 = "result")} lyt <- lyt_rows %>% - analyze_pk_vars_in_cols( + analyze_vars_in_cols( vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), - imp_rule = "1/2" + .stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"), + .formats = c( + n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), + geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3) + ), + .labels = c( + n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", + geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" + ), + imp_rule = "1/2", + .aligns = "decimal" ) result <- build_table(lyt, df = adpc_1) %>% prune_table() diff --git a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md index 808f618d1..a81a9cfde 100644 --- a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md +++ b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md @@ -17,7 +17,7 @@ ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— A: Drug X Day 1 - 0 134 134 0 0 NE NE NE 0 0 0 + 0 134 134 0 0 NE 0 NE 0 0 0 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 @@ -27,7 +27,7 @@ 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 Day 2 - 24 134 134 0 0 NE NE NE 0 0 0 + 24 134 134 0 0 NE 0 NE 0 0 0 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable @@ -52,16 +52,16 @@ A: Drug X Day 1 0 134 134 ND ND ND NE ND 0 ND 0 - 0.5 134 0 12.6 1.51 12.0 NE 12.2 12.6 9.72 15.6 - 1 134 0 16.2 1.63 10.0 NE 10.1 16.2 12.6 19.9 - 1.5 134 0 15.6 1.46 9.3 NE 9.3 15.5 12.3 19 - 2 134 0 13.4 1.35 10.1 NE 10.0 13.3 10.8 16.5 - 3 134 0 8.47 1.25 14.7 NE 15.0 8.4 5.88 10.9 - 4 134 0 4.79 1.02 21.2 NE 22.0 4.79 2.7 7.09 - 8 134 0 0.348 0.18 51.7 NE 58.4 0.318 0.076 0.866 - 12 134 0 0.0224 0.0189 84.6 NE 111.6 0.017 0.002 0.083 + 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 + 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 + 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 + 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 + 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 Day 2 - 24 134 134 ND ND ND NE ND 0 ND 0 + 24 134 134 ND ND ND 0 ND 0 ND 0 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable From 0b3d38b81ed0e22fd0e2e05f2f2f69d849a20f5c Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 31 Aug 2023 01:21:04 +0000 Subject: [PATCH 05/12] [skip actions] Restyle files --- book/tables/pharmacokinetic/pkct01.qmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index 9aa6e7a89..3c2abcbe0 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -60,11 +60,11 @@ lyt <- lyt_rows %>% vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), .stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"), .formats = c( - n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), + n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3) ), .labels = c( - n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", + n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" ), na_level = "NE", @@ -89,11 +89,11 @@ lyt <- lyt_rows %>% vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), .stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"), .formats = c( - n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), + n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3) ), .labels = c( - n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", + n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" ), imp_rule = "1/3", @@ -118,11 +118,11 @@ lyt <- lyt_rows %>% vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)), .stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"), .formats = c( - n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), + n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3), geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3) ), .labels = c( - n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", + n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" ), imp_rule = "1/2", From f6d52f02de44de5c34351ac54d9da8bd6ba0637f Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Wed, 30 Aug 2023 21:24:30 -0400 Subject: [PATCH 06/12] Empty commit From dec7da5572c53492b506d073313fe232ea9df39d Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 31 Aug 2023 13:04:38 -0400 Subject: [PATCH 07/12] Empty commit From 74ba9396a52e10044cb0992fb8ccd9a975389796 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 7 Sep 2023 10:44:04 -0400 Subject: [PATCH 08/12] Add FLAGSUM to data for PKCT01 --- book/tables/pharmacokinetic/pkct01.qmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index 3c2abcbe0..9c14c3161 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -23,10 +23,11 @@ adpc <- synthetic_cdisc_dataset("latest", "adpc") adpc_1 <- adpc %>% mutate( NFRLT = as.factor(NFRLT), - AVALCAT1 = as.factor(AVALCAT1) + AVALCAT1 = as.factor(AVALCAT1), + FLAGSUM = AVALCAT1 %in% c("BLQ", "LTR", "% filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X") %>% - select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>% + select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1, FLAGSUM) %>% var_relabel(NFRLT = "Nominal Time from First Dose (hr)") # Row structure From 00e826140e4f0554e287c9f1db9ac9e17c3fe077 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 7 Sep 2023 11:01:24 -0400 Subject: [PATCH 09/12] Revert to use AVALCAT1 directly instead of FLAGSUM --- book/tables/pharmacokinetic/pkct01.qmd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index 9c14c3161..3c2abcbe0 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -23,11 +23,10 @@ adpc <- synthetic_cdisc_dataset("latest", "adpc") adpc_1 <- adpc %>% mutate( NFRLT = as.factor(NFRLT), - AVALCAT1 = as.factor(AVALCAT1), - FLAGSUM = AVALCAT1 %in% c("BLQ", "LTR", "% filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X") %>% - select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1, FLAGSUM) %>% + select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>% var_relabel(NFRLT = "Nominal Time from First Dose (hr)") # Row structure From 135b58d67d2032d4b6d943bb7daaf55b013f4fbb Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 7 Sep 2023 12:39:56 -0400 Subject: [PATCH 10/12] Add row counts, refresh snapshots --- book/tables/pharmacokinetic/pkct01.qmd | 13 +- .../testthat/_snaps/pkct01/markdown-snaps.md | 126 +++++++++--------- 2 files changed, 71 insertions(+), 68 deletions(-) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index 3c2abcbe0..9e9cc4aff 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -17,7 +17,10 @@ library(scda) library(dplyr) library(tern) -adpc <- synthetic_cdisc_dataset("latest", "adpc") +adsl <- synthetic_cdisc_dataset("latest", "adsl") %>% + filter(ACTARM == "A: Drug X") +adpc <- synthetic_cdisc_dataset("latest", "adpc") %>% + filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X") # Setting up the data adpc_1 <- adpc %>% @@ -25,7 +28,6 @@ adpc_1 <- adpc %>% NFRLT = as.factor(NFRLT), AVALCAT1 = as.factor(AVALCAT1) ) %>% - filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X") %>% select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>% var_relabel(NFRLT = "Nominal Time from First Dose (hr)") @@ -37,6 +39,7 @@ lyt_rows <- basic_table() %>% split_label = "Treatment Group", label_pos = "topleft" ) %>% + add_rowcounts(alt_counts = TRUE) %>% split_rows_by( var = "VISIT", split_fun = drop_split_levels, @@ -71,7 +74,7 @@ lyt <- lyt_rows %>% .aligns = "decimal" ) -result <- build_table(lyt, df = adpc_1) %>% prune_table() +result <- build_table(lyt, df = adpc_1, alt_counts_df = adsl) %>% prune_table() # Decorating main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" @@ -100,7 +103,7 @@ lyt <- lyt_rows %>% .aligns = "decimal" ) -result <- build_table(lyt, df = adpc_1) %>% prune_table() +result <- build_table(lyt, df = adpc_1, alt_counts_df = adsl) %>% prune_table() # Decorating main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" @@ -129,7 +132,7 @@ lyt <- lyt_rows %>% .aligns = "decimal" ) -result <- build_table(lyt, df = adpc_1) %>% prune_table() +result <- build_table(lyt, df = adpc_1, alt_counts_df = adsl) %>% prune_table() # Decorate table main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable" diff --git a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md index a81a9cfde..345e5da16 100644 --- a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md +++ b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md @@ -8,27 +8,27 @@ Analyte: Plasma Drug X Treatment: A: Drug X - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Treatment Group - Visit - Nominal Time from First Dose (hr) Number - of - n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X - Day 1 - 0 134 134 0 0 NE 0 NE 0 0 0 - 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 - 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 - 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 - 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 - 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 - 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 - 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 - 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 - Day 2 - 24 134 134 0 0 NE 0 NE 0 0 0 - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Group + Visit + Nominal Time from First Dose (hr) Number + of + n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X (N=134) + Day 1 + 0 134 134 0 0 NE 0 NE 0 0 0 + 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19.0 + 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 8.38 15.0 8.40 5.88 10.9 + 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.70 7.09 + 8 134 0 0.348 0.180 51.7 0.303 58.4 0.318 0.0760 0.866 + 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.0170 0.00200 0.0830 + Day 2 + 24 134 134 0 0 NE 0 NE 0 0 0 + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable @@ -42,27 +42,27 @@ Analyte: Plasma Drug X Treatment: A: Drug X - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Treatment Group - Visit - Nominal Time from First Dose (hr) Number - of - n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X - Day 1 - 0 134 134 ND ND ND NE ND 0 ND 0 - 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 - 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 - 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 - 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 - 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 - 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 - 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 - 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 - Day 2 - 24 134 134 ND ND ND 0 ND 0 ND 0 - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Group + Visit + Nominal Time from First Dose (hr) Number + of + n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X (N=134) + Day 1 + 0 134 134 ND ND ND NE ND 0 ND 0 + 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19.0 + 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 8.38 15.0 8.40 5.88 10.9 + 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.70 7.09 + 8 134 0 0.348 0.180 51.7 0.303 58.4 0.318 0.0760 0.866 + 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.0170 0.00200 0.0830 + Day 2 + 24 134 134 ND ND ND 0 ND 0 ND 0 + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable ND: Not Derived @@ -77,27 +77,27 @@ Analyte: Plasma Drug X Treatment: A: Drug X - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Treatment Group - Visit - Nominal Time from First Dose (hr) Number - of - n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - A: Drug X - Day 1 - 0 134 134 ND ND ND ND ND ND ND 0 - 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 - 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 - 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 - 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 - 3 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 - 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.7 7.09 - 8 134 0 0.348 0.18 51.7 0.303 58.4 0.318 0.076 0.866 - 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.017 0.002 0.083 - Day 2 - 24 134 134 ND ND ND ND ND ND ND 0 - ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Group + Visit + Nominal Time from First Dose (hr) Number + of + n LTRs/BLQs Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X (N=134) + Day 1 + 0 134 134 ND ND ND ND ND ND ND 0 + 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19.0 + 2 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 134 0 8.47 1.25 14.7 8.38 15.0 8.40 5.88 10.9 + 4 134 0 4.79 1.02 21.2 4.69 22.0 4.79 2.70 7.09 + 8 134 0 0.348 0.180 51.7 0.303 58.4 0.318 0.0760 0.866 + 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.0170 0.00200 0.0830 + Day 2 + 24 134 134 ND ND ND ND ND ND ND 0 + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— ND: Not Derived From 6bd98e7863fc7252d637695521cf9551c191e415 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 8 Sep 2023 10:50:32 -0400 Subject: [PATCH 11/12] Update snapshot geom_mean --- package/tests/testthat/_snaps/pkct01/markdown-snaps.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md index 345e5da16..6559af69e 100644 --- a/package/tests/testthat/_snaps/pkct01/markdown-snaps.md +++ b/package/tests/testthat/_snaps/pkct01/markdown-snaps.md @@ -17,7 +17,7 @@ —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— A: Drug X (N=134) Day 1 - 0 134 134 0 0 NE 0 NE 0 0 0 + 0 134 134 0 0 NE NE NE 0 0 0 0.5 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 1 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 1.5 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19.0 @@ -27,7 +27,7 @@ 8 134 0 0.348 0.180 51.7 0.303 58.4 0.318 0.0760 0.866 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.0170 0.00200 0.0830 Day 2 - 24 134 134 0 0 NE 0 NE 0 0 0 + 24 134 134 0 0 NE NE NE 0 0 0 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable @@ -61,7 +61,7 @@ 8 134 0 0.348 0.180 51.7 0.303 58.4 0.318 0.0760 0.866 12 134 0 0.0224 0.0189 84.6 0.0156 111.6 0.0170 0.00200 0.0830 Day 2 - 24 134 134 ND ND ND 0 ND 0 ND 0 + 24 134 134 ND ND ND NE ND 0 ND 0 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— NE: Not Estimable From a9e1d59925b96966397d50075fd86030712e1afb Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 8 Sep 2023 12:54:39 -0400 Subject: [PATCH 12/12] Use caching --- book/tables/pharmacokinetic/pkct01.qmd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/book/tables/pharmacokinetic/pkct01.qmd b/book/tables/pharmacokinetic/pkct01.qmd index 9e9cc4aff..7c9c05095 100644 --- a/book/tables/pharmacokinetic/pkct01.qmd +++ b/book/tables/pharmacokinetic/pkct01.qmd @@ -70,6 +70,7 @@ lyt <- lyt_rows %>% n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" ), + cache = TRUE, na_level = "NE", .aligns = "decimal" ) @@ -99,6 +100,7 @@ lyt <- lyt_rows %>% n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" ), + cache = TRUE, imp_rule = "1/3", .aligns = "decimal" ) @@ -128,6 +130,7 @@ lyt <- lyt_rows %>% n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean", geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum" ), + cache = TRUE, imp_rule = "1/2", .aligns = "decimal" )