diff --git a/book/tables/pharmacokinetic/pkpt02.qmd b/book/tables/pharmacokinetic/pkpt02.qmd index b884d1e10c..6b62066ee7 100644 --- a/book/tables/pharmacokinetic/pkpt02.qmd +++ b/book/tables/pharmacokinetic/pkpt02.qmd @@ -19,24 +19,6 @@ library(tern) adpp <- synthetic_cdisc_dataset("latest", "adpp") adpp <- adpp %>% filter(PPSPEC == "Plasma", AVISIT == "CYCLE 1 DAY 1") - -fmt_sigfig_mean_sd <- function(sigfig) { - checkmate::assert_integerish(sigfig) - function(x, ...) { - if (!is.numeric(x)) stop("`format_sigfig` cannot be used for non-numeric values. Please choose another format.") - num <- gsub("\\.$", "", formatC(signif(x, digits = sigfig), digits = sigfig, format = "fg", flag = "#")) - paste0(num[1], " (", num[2], ")") - } -} - -fmt_sigfig_range <- function(sigfig) { - checkmate::assert_integerish(sigfig) - function(x, ...) { - if (!is.numeric(x)) stop("`format_sigfig` cannot be used for non-numeric values. Please choose another format.") - num <- gsub("\\.$", "", formatC(signif(x, digits = sigfig), digits = sigfig, format = "fg", flag = "#")) - paste0(num[1], " - ", num[2]) - } -} ``` ## Standard Table -- Plasma @@ -60,12 +42,12 @@ lyt <- basic_table() %>% .stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"), .formats = c( n = "xx.", - mean_sd = fmt_sigfig_mean_sd(3), + mean_sd = format_sigfig(3, "value_paren"), cv = "xx.x", geom_mean = format_sigfig(3), geom_cv = "xx.x", median = format_sigfig(3), - range = fmt_sigfig_range(3) + range = format_sigfig(3, "range") ) ) ``` diff --git a/book/tables/pharmacokinetic/pkpt04.qmd b/book/tables/pharmacokinetic/pkpt04.qmd index 322704357b..b1a6f41487 100644 --- a/book/tables/pharmacokinetic/pkpt04.qmd +++ b/book/tables/pharmacokinetic/pkpt04.qmd @@ -19,24 +19,6 @@ library(tern) adpp <- synthetic_cdisc_dataset("latest", "adpp") adpp <- adpp %>% filter(PPSPEC == "Urine", AVISIT == "CYCLE 1 DAY 1") - -fmt_sigfig_mean_sd <- function(sigfig) { - checkmate::assert_integerish(sigfig) - function(x, ...) { - if (!is.numeric(x)) stop("`format_sigfig` cannot be used for non-numeric values. Please choose another format.") - num <- gsub("\\.$", "", formatC(signif(x, digits = sigfig), digits = sigfig, format = "fg", flag = "#")) - paste0(num[1], " (", num[2], ")") - } -} - -fmt_sigfig_range <- function(sigfig) { - checkmate::assert_integerish(sigfig) - function(x, ...) { - if (!is.numeric(x)) stop("`format_sigfig` cannot be used for non-numeric values. Please choose another format.") - num <- gsub("\\.$", "", formatC(signif(x, digits = sigfig), digits = sigfig, format = "fg", flag = "#")) - paste0(num[1], " - ", num[2]) - } -} ``` ## Standard Table @@ -60,12 +42,12 @@ lyt <- basic_table() %>% .stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"), .formats = c( n = "xx.", - mean_sd = fmt_sigfig_mean_sd(3), + mean_sd = format_sigfig(3, "value_paren"), cv = "xx.x", geom_mean = format_sigfig(3), geom_cv = "xx.x", median = format_sigfig(3), - range = fmt_sigfig_range(3) + range = format_sigfig(3, "range") ) ) ``` diff --git a/book/tables/pharmacokinetic/pkpt06.qmd b/book/tables/pharmacokinetic/pkpt06.qmd index 19edb00666..346ae6592c 100644 --- a/book/tables/pharmacokinetic/pkpt06.qmd +++ b/book/tables/pharmacokinetic/pkpt06.qmd @@ -20,24 +20,6 @@ library(stringr) adpp <- synthetic_cdisc_dataset("latest", "adpp") adpp <- adpp %>% filter(AVISIT == "CYCLE 1 DAY 1", str_detect(tolower(PARAM), regex("norm by dose", ignore_case = TRUE))) - -fmt_sigfig_mean_sd <- function(sigfig) { - checkmate::assert_integerish(sigfig) - function(x, ...) { - if (!is.numeric(x)) stop("`format_sigfig` cannot be used for non-numeric values. Please choose another format.") - num <- gsub("\\.$", "", formatC(signif(x, digits = sigfig), digits = sigfig, format = "fg", flag = "#")) - paste0(num[1], " (", num[2], ")") - } -} - -fmt_sigfig_range <- function(sigfig) { - checkmate::assert_integerish(sigfig) - function(x, ...) { - if (!is.numeric(x)) stop("`format_sigfig` cannot be used for non-numeric values. Please choose another format.") - num <- gsub("\\.$", "", formatC(signif(x, digits = sigfig), digits = sigfig, format = "fg", flag = "#")) - paste0(num[1], " - ", num[2]) - } -} ``` ## Standard Table @@ -61,12 +43,12 @@ lyt <- basic_table() %>% .stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"), .formats = c( n = "xx.", - mean_sd = fmt_sigfig_mean_sd(3), + mean_sd = format_sigfig(3, "value_paren"), cv = "xx.x", geom_mean = format_sigfig(3), geom_cv = "xx.x", median = format_sigfig(3), - range = fmt_sigfig_range(3) + range = format_sigfig(3, "range") ) ) ```