From c35948a59c974cc42d5341065481696a17121e2d Mon Sep 17 00:00:00 2001 From: Ilse Augustyns Date: Mon, 9 Sep 2024 08:04:30 +0000 Subject: [PATCH 01/10] add 3 new stats to surv_time --- R/survival_time.R | 36 ++++++++++++++++++++++---- R/utils_default_stats_formats_labels.R | 22 +++++++++++++++- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/R/survival_time.R b/R/survival_time.R index fd13f0ce73..3555bd17d8 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -70,10 +70,22 @@ s_surv_time <- function(df, conf.type = conf_type ) srv_tab <- summary(srv_fit, extend = TRUE)$table - srv_qt_tab <- stats::quantile(srv_fit, probs = quantiles)$quantile + srv_qt_tab_pre <- stats::quantile(srv_fit, probs = quantiles) + srv_qt_tab <- srv_qt_tab_pre$quantile range_censor <- range_noinf(df[[.var]][!df[[is_event]]], na.rm = TRUE) range_event <- range_noinf(df[[.var]][df[[is_event]]], na.rm = TRUE) range <- range_noinf(df[[.var]], na.rm = TRUE) + + names(quantiles) <- as.character(100*quantiles) + srv_qt_tab_pre <- unlist(srv_qt_tab_pre) + srv_qt_ci <- lapply(quantiles, function(x){ + name <- as.character(100*x) + + c(srv_qt_tab_pre[[paste0("quantile.",name)]], + srv_qt_tab_pre[[paste0("lower.",name)]], + srv_qt_tab_pre[[paste0("upper.",name)]]) + }) + list( median = formatters::with_label(unname(srv_tab["median"]), "Median"), median_ci = formatters::with_label( @@ -84,7 +96,16 @@ s_surv_time <- function(df, ), range_censor = formatters::with_label(range_censor, "Range (censored)"), range_event = formatters::with_label(range_event, "Range (event)"), - range = formatters::with_label(range, "Range") + range = formatters::with_label(range, "Range"), + median_ci_1_line = formatters::with_label(c(unname(srv_tab["median"]),unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), + paste0("Median ",f_conf_level(conf_level))), + quantiles_ci_1 = formatters::with_label( + unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile with ", f_conf_level(conf_level)) + ), + quantiles_ci_2 = formatters::with_label( + unname(srv_qt_ci[[2]]), paste0(quantiles[2] * 100, "%-ile with ", f_conf_level(conf_level)) + ) + ) } @@ -121,8 +142,13 @@ a_surv_time <- function(df, rng_censor_upr <- x_stats[["range_censor"]][2] # Use method-specific defaults - fmts <- c(median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x") - lbls <- c(median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)") + fmts <- c(median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x", + median_ci_1_line = "xx.x (xx.x - xx.x)", + quantiles_ci_1 = "xx.x (xx.x - xx.x)", quantiles_ci_2 = "xx.x (xx.x - xx.x)") + lbls <- c(median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)", + median_ci_1_line = "Median 95% CI", + quantiles_ci_1 = "25%-ile with 95% CI", + quantiles_ci_2 = "75%-ile with 95% CI") lbls_custom <- .labels .formats <- c(.formats, fmts[setdiff(names(fmts), names(.formats))]) .labels <- c(.labels, lbls[setdiff(names(lbls), names(lbls_custom))]) @@ -209,7 +235,7 @@ surv_time <- function(lyt, var_labels = var_labels, show_labels = show_labels, table_names = table_names, - na_str = na_str, + #na_str = na_str, nested = nested, extra_args = extra_args ) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 34cc8937a1..f3ff415111 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -344,6 +344,20 @@ labels_use_control <- function(labels_default, control, labels_custom = NULL) { labels_default["quantiles"] ) } + if ("quantiles" %in% names(control) && "quantiles_ci_1" %in% names(labels_default) && + !"quantiles_ci_1" %in% names(labels_custom)) { # nolint + labels_default["quantiles_ci_1"] <- gsub( + "[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100,"%-ile",""), + labels_default["quantiles_ci_1"] + ) + } + if ("quantiles" %in% names(control) && "quantiles_ci_2" %in% names(labels_default) && + !"quantiles_ci_2" %in% names(labels_custom)) { # nolint + labels_default["quantiles_ci_2"] <- gsub( + "[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100,"%-ile",""), + labels_default["quantiles_ci_2"] + ) + } if ("test_mean" %in% names(control) && "mean_pval" %in% names(labels_default) && !"mean_pval" %in% names(labels_custom)) { # nolint labels_default["mean_pval"] <- gsub( @@ -392,7 +406,7 @@ tern_default_stats <- list( summarize_glm_count = c("n", "rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"), summarize_num_patients = c("unique", "nonunique", "unique_count"), summarize_patients_events_in_cols = c("unique", "all"), - surv_time = c("median", "median_ci", "quantiles", "range_censor", "range_event", "range"), + surv_time = c("median", "median_ci", "median_ci_1_line", "quantiles", "quantiles_ci_1", "quantiles_ci_2", "range_censor", "range_event", "range"), surv_timepoint = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval"), tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), @@ -431,7 +445,10 @@ tern_default_formats <- c( median = "xx.x", mad = "xx.x", median_ci = "(xx.xx, xx.xx)", + median_ci_1_line = "xx.xx (xx.xx, xx.xx)", quantiles = "xx.x - xx.x", + quantiles_ci_1 = "xx.xx (xx.xx, xx.xx)", + quantiles_ci_2 = "xx.xx (xx.xx, xx.xx)", iqr = "xx.x", range = "xx.x - xx.x", min = "xx.x", @@ -480,7 +497,10 @@ tern_default_labels <- c( median = "Median", mad = "Median Absolute Deviation", median_ci = "Median 95% CI", + median_ci_1_line = "Median 95% CI", quantiles = "25% and 75%-ile", + quantiles_ci_1 = "25%-ile 95% CI", + quantiles_ci_2 = "75%-ile 95% CI", iqr = "IQR", range = "Min - Max", min = "Minimum", From 56b5f293adc37d3e63d33520d749391b2f323897 Mon Sep 17 00:00:00 2001 From: iaugusty Date: Mon, 9 Sep 2024 12:36:05 +0000 Subject: [PATCH 02/10] update test snapshot for survival_time --- tests/testthat/_snaps/survival_time.md | 68 ++++++++++++++++++++------ 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/tests/testthat/_snaps/survival_time.md b/tests/testthat/_snaps/survival_time.md index b3779dd04d..0405f2bbe7 100644 --- a/tests/testthat/_snaps/survival_time.md +++ b/tests/testthat/_snaps/survival_time.md @@ -33,6 +33,21 @@ attr(,"label") [1] "Range" + $median_ci_1_line + [1] 23.91143 18.25878 32.85945 + attr(,"label") + [1] "Median 95% CI" + + $quantiles_ci_1 + [1] 9.822926 5.628823 16.690121 + attr(,"label") + [1] "25%-ile with 95% CI" + + $quantiles_ci_2 + [1] 41.98181 32.85945 53.41445 + attr(,"label") + [1] "75%-ile with 95% CI" + # s_surv_time works with customized arguments @@ -69,6 +84,21 @@ attr(,"label") [1] "Range" + $median_ci_1_line + [1] 23.91143 13.59124 37.97055 + attr(,"label") + [1] "Median 99% CI" + + $quantiles_ci_1 + [1] 6.649204 1.887860 12.771697 + attr(,"label") + [1] "20%-ile with 99% CI" + + $quantiles_ci_2 + [1] 51.09487 37.97055 NA + attr(,"label") + [1] "80%-ile with 99% CI" + # a_surv_time works with default arguments @@ -77,13 +107,16 @@ Output RowsVerticalSection (in_rows) object print method: ---------------------------- - row_name formatted_cell indent_mod row_label - 1 Median 24.8 0 Median - 2 95% CI (21.1, 31.3) 0 95% CI - 3 25% and 75%-ile 10.8, 47.6 0 25% and 75%-ile - 4 Range (censored) 0.8 to 78.9 0 Range (censored) - 5 Range (event) 0.1 to 155.5 0 Range (event) - 6 Range 0.1 to 155.5 0 Range + row_name formatted_cell indent_mod row_label + 1 Median 24.8 0 Median + 2 95% CI (21.1, 31.3) 0 95% CI + 3 Median 95% CI 24.8 (21.1 - 31.3) 0 Median 95% CI + 4 25% and 75%-ile 10.8, 47.6 0 25% and 75%-ile + 5 25%-ile with 95% CI 10.8 (6.6 - 13.4) 0 25%-ile with 95% CI + 6 75%-ile with 95% CI 47.6 (39.3 - 57.8) 0 75%-ile with 95% CI + 7 Range (censored) 0.8 to 78.9 0 Range (censored) + 8 Range (event) 0.1 to 155.5 0 Range (event) + 9 Range 0.1 to 155.5 0 Range # a_surv_time works with customized arguments @@ -115,15 +148,18 @@ Code res Output - ARM A ARM B ARM C - ——————————————————————————————————————————————————————————————————— - Survival Time (Months) - Median 32.0 23.9 20.8 - 90% CI (25.6, 49.3) (18.9, 32.1) (13.0, 26.0) - 40% and 60%-ile 25.6, 46.5 18.3, 29.2 13.0, 25.7 - Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4 - Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 - Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 + ARM A ARM B ARM C + ————————————————————————————————————————————————————————————————————————————————————— + Survival Time (Months) + Median 32.0 23.9 20.8 + 90% CI (25.6, 49.3) (18.9, 32.1) (13.0, 26.0) + Median 90% CI 32.0 (25.6 - 49.3) 23.9 (18.9 - 32.1) 20.8 (13.0 - 26.0) + 40% and 60%-ile 25.6, 46.5 18.3, 29.2 13.0, 25.7 + 40%-ile with 90% CI 25.6 (20.7 - 33.4) 18.3 (12.8 - 23.9) 13.0 (10.1 - 24.8) + 60%-ile with 90% CI 46.5 (32.0 - 57.8) 29.2 (23.9 - 41.3) 25.7 (20.8 - 37.1) + Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4 + Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 + Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 # surv_time works with referential footnotes From 3bc7d426189d96b26adecc2eaade354b214e6061 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:47:13 +0000 Subject: [PATCH 03/10] [skip style] [skip vbump] Restyle files --- R/survival_time.R | 41 +++++++++++++++----------- R/utils_default_stats_formats_labels.R | 8 ++--- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/R/survival_time.R b/R/survival_time.R index 3555bd17d8..153263d393 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -76,14 +76,16 @@ s_surv_time <- function(df, range_event <- range_noinf(df[[.var]][df[[is_event]]], na.rm = TRUE) range <- range_noinf(df[[.var]], na.rm = TRUE) - names(quantiles) <- as.character(100*quantiles) + names(quantiles) <- as.character(100 * quantiles) srv_qt_tab_pre <- unlist(srv_qt_tab_pre) - srv_qt_ci <- lapply(quantiles, function(x){ - name <- as.character(100*x) + srv_qt_ci <- lapply(quantiles, function(x) { + name <- as.character(100 * x) - c(srv_qt_tab_pre[[paste0("quantile.",name)]], - srv_qt_tab_pre[[paste0("lower.",name)]], - srv_qt_tab_pre[[paste0("upper.",name)]]) + c( + srv_qt_tab_pre[[paste0("quantile.", name)]], + srv_qt_tab_pre[[paste0("lower.", name)]], + srv_qt_tab_pre[[paste0("upper.", name)]] + ) }) list( @@ -97,15 +99,16 @@ s_surv_time <- function(df, range_censor = formatters::with_label(range_censor, "Range (censored)"), range_event = formatters::with_label(range_event, "Range (event)"), range = formatters::with_label(range, "Range"), - median_ci_1_line = formatters::with_label(c(unname(srv_tab["median"]),unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), - paste0("Median ",f_conf_level(conf_level))), + median_ci_1_line = formatters::with_label( + c(unname(srv_tab["median"]), unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), + paste0("Median ", f_conf_level(conf_level)) + ), quantiles_ci_1 = formatters::with_label( unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile with ", f_conf_level(conf_level)) ), quantiles_ci_2 = formatters::with_label( unname(srv_qt_ci[[2]]), paste0(quantiles[2] * 100, "%-ile with ", f_conf_level(conf_level)) ) - ) } @@ -142,13 +145,17 @@ a_surv_time <- function(df, rng_censor_upr <- x_stats[["range_censor"]][2] # Use method-specific defaults - fmts <- c(median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x", - median_ci_1_line = "xx.x (xx.x - xx.x)", - quantiles_ci_1 = "xx.x (xx.x - xx.x)", quantiles_ci_2 = "xx.x (xx.x - xx.x)") - lbls <- c(median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)", - median_ci_1_line = "Median 95% CI", - quantiles_ci_1 = "25%-ile with 95% CI", - quantiles_ci_2 = "75%-ile with 95% CI") + fmts <- c( + median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x", + median_ci_1_line = "xx.x (xx.x - xx.x)", + quantiles_ci_1 = "xx.x (xx.x - xx.x)", quantiles_ci_2 = "xx.x (xx.x - xx.x)" + ) + lbls <- c( + median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)", + median_ci_1_line = "Median 95% CI", + quantiles_ci_1 = "25%-ile with 95% CI", + quantiles_ci_2 = "75%-ile with 95% CI" + ) lbls_custom <- .labels .formats <- c(.formats, fmts[setdiff(names(fmts), names(.formats))]) .labels <- c(.labels, lbls[setdiff(names(lbls), names(lbls_custom))]) @@ -235,7 +242,7 @@ surv_time <- function(lyt, var_labels = var_labels, show_labels = show_labels, table_names = table_names, - #na_str = na_str, + # na_str = na_str, nested = nested, extra_args = extra_args ) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index f3ff415111..14a5f7aacd 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -345,16 +345,16 @@ labels_use_control <- function(labels_default, control, labels_custom = NULL) { ) } if ("quantiles" %in% names(control) && "quantiles_ci_1" %in% names(labels_default) && - !"quantiles_ci_1" %in% names(labels_custom)) { # nolint + !"quantiles_ci_1" %in% names(labels_custom)) { # nolint labels_default["quantiles_ci_1"] <- gsub( - "[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100,"%-ile",""), + "[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100, "%-ile", ""), labels_default["quantiles_ci_1"] ) } if ("quantiles" %in% names(control) && "quantiles_ci_2" %in% names(labels_default) && - !"quantiles_ci_2" %in% names(labels_custom)) { # nolint + !"quantiles_ci_2" %in% names(labels_custom)) { # nolint labels_default["quantiles_ci_2"] <- gsub( - "[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100,"%-ile",""), + "[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100, "%-ile", ""), labels_default["quantiles_ci_2"] ) } From a65114aa768defd5978bbdb999dd0e55ad01d3f3 Mon Sep 17 00:00:00 2001 From: iaugusty Date: Mon, 9 Sep 2024 13:39:28 +0000 Subject: [PATCH 04/10] fix lint checks --- R/survival_time.R | 19 ++++++++++--------- R/utils_default_stats_formats_labels.R | 8 +++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/R/survival_time.R b/R/survival_time.R index 3555bd17d8..8f78b9cf0e 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -76,14 +76,14 @@ s_surv_time <- function(df, range_event <- range_noinf(df[[.var]][df[[is_event]]], na.rm = TRUE) range <- range_noinf(df[[.var]], na.rm = TRUE) - names(quantiles) <- as.character(100*quantiles) + names(quantiles) <- as.character(100 * quantiles) srv_qt_tab_pre <- unlist(srv_qt_tab_pre) - srv_qt_ci <- lapply(quantiles, function(x){ - name <- as.character(100*x) + srv_qt_ci <- lapply(quantiles, function(x) { + name <- as.character(100 * x) - c(srv_qt_tab_pre[[paste0("quantile.",name)]], - srv_qt_tab_pre[[paste0("lower.",name)]], - srv_qt_tab_pre[[paste0("upper.",name)]]) + c(srv_qt_tab_pre[[paste0("quantile.", name)]], + srv_qt_tab_pre[[paste0("lower.", name)]], + srv_qt_tab_pre[[paste0("upper.", name)]]) }) list( @@ -97,8 +97,10 @@ s_surv_time <- function(df, range_censor = formatters::with_label(range_censor, "Range (censored)"), range_event = formatters::with_label(range_event, "Range (event)"), range = formatters::with_label(range, "Range"), - median_ci_1_line = formatters::with_label(c(unname(srv_tab["median"]),unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), - paste0("Median ",f_conf_level(conf_level))), + median_ci_1_line = formatters::with_label( + c(unname(srv_tab["median"]), + unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), + paste0("Median ", f_conf_level(conf_level))), quantiles_ci_1 = formatters::with_label( unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile with ", f_conf_level(conf_level)) ), @@ -235,7 +237,6 @@ surv_time <- function(lyt, var_labels = var_labels, show_labels = show_labels, table_names = table_names, - #na_str = na_str, nested = nested, extra_args = extra_args ) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index f3ff415111..41a48374ee 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -347,14 +347,14 @@ labels_use_control <- function(labels_default, control, labels_custom = NULL) { if ("quantiles" %in% names(control) && "quantiles_ci_1" %in% names(labels_default) && !"quantiles_ci_1" %in% names(labels_custom)) { # nolint labels_default["quantiles_ci_1"] <- gsub( - "[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100,"%-ile",""), + "[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100, "%-ile", ""), labels_default["quantiles_ci_1"] ) } if ("quantiles" %in% names(control) && "quantiles_ci_2" %in% names(labels_default) && !"quantiles_ci_2" %in% names(labels_custom)) { # nolint labels_default["quantiles_ci_2"] <- gsub( - "[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100,"%-ile",""), + "[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100, "%-ile", ""), labels_default["quantiles_ci_2"] ) } @@ -406,7 +406,9 @@ tern_default_stats <- list( summarize_glm_count = c("n", "rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"), summarize_num_patients = c("unique", "nonunique", "unique_count"), summarize_patients_events_in_cols = c("unique", "all"), - surv_time = c("median", "median_ci", "median_ci_1_line", "quantiles", "quantiles_ci_1", "quantiles_ci_2", "range_censor", "range_event", "range"), + surv_time = c( + "median", "median_ci", "median_ci_1_line", "quantiles", + "quantiles_ci_1", "quantiles_ci_2", "range_censor", "range_event", "range"), surv_timepoint = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval"), tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), From 881f5e77292c4373aa27f70706bd4370af8a8c69 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:02:12 +0000 Subject: [PATCH 05/10] [skip style] [skip vbump] Restyle files --- R/survival_time.R | 9 ++++++--- R/utils_default_stats_formats_labels.R | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/survival_time.R b/R/survival_time.R index c12f9f489e..15be7fef69 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -100,9 +100,12 @@ s_surv_time <- function(df, range_event = formatters::with_label(range_event, "Range (event)"), range = formatters::with_label(range, "Range"), median_ci_1_line = formatters::with_label( - c(unname(srv_tab["median"]), - unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), - paste0("Median ", f_conf_level(conf_level))), + c( + unname(srv_tab["median"]), + unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))]) + ), + paste0("Median ", f_conf_level(conf_level)) + ), quantiles_ci_1 = formatters::with_label( unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile with ", f_conf_level(conf_level)) ), diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index bef5407352..f6212d5678 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -408,7 +408,8 @@ tern_default_stats <- list( summarize_patients_events_in_cols = c("unique", "all"), surv_time = c( "median", "median_ci", "median_ci_1_line", "quantiles", - "quantiles_ci_1", "quantiles_ci_2", "range_censor", "range_event", "range"), + "quantiles_ci_1", "quantiles_ci_2", "range_censor", "range_event", "range" + ), surv_timepoint = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval"), tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), From 98ff6c87e74619dac31eda9494298697a8fa0d0d Mon Sep 17 00:00:00 2001 From: iaugusty Date: Tue, 10 Sep 2024 09:14:46 +0000 Subject: [PATCH 06/10] renaming stats per review suggestion --- NEWS.md | 4 ++ R/survival_coxph_pairwise.R | 7 ++- R/survival_time.R | 29 ++++++----- R/survival_timepoint.R | 17 +++++-- R/utils_default_stats_formats_labels.R | 39 ++++++++------- .../_snaps/survival_coxph_pairwise.md | 20 ++++++++ tests/testthat/_snaps/survival_time.md | 50 +++++++++---------- tests/testthat/_snaps/survival_timepoint.md | 25 ++++++++++ 8 files changed, 131 insertions(+), 60 deletions(-) diff --git a/NEWS.md b/NEWS.md index 63d4ee5c43..de3a855853 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # tern 0.9.5.9021 ### Enhancements +* Added `median_long`, `quantiles_lower` and `quantiles_upper` to `s_surv_time` which includes estimate and confidence interval in one statistic. +* Added `hr_long` to `s_coxph_pairwise` which includes estimate and confidence interval in one statistic. +* Added `event_free_rate_long` to `s_surv_timepoint` which includes estimate and confidence interval in one statistic. +* Added `rate_diff_long` to `s_surv_timepoint_diff` which includes estimate and confidence interval in one statistic. * Added `errorbar_width` and `linetype` parameters to `g_lineplot`. * Reworking of `summarize_glm_count()` documentation and all its associated functions to better describe the results and the functions' purpose. * Added the `.formats` argument to `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` to allow users to specify formats. diff --git a/R/survival_coxph_pairwise.R b/R/survival_coxph_pairwise.R index 88ec24b68e..be30d237bc 100644 --- a/R/survival_coxph_pairwise.R +++ b/R/survival_coxph_pairwise.R @@ -65,6 +65,7 @@ s_coxph_pairwise <- function(df, pvalue = formatters::with_label("", paste0("p-value (", pval_method, ")")), hr = formatters::with_label("", "Hazard Ratio"), hr_ci = formatters::with_label("", f_conf_level(conf_level)), + hr_long = formatters::with_label("", paste0("Hazard Ratio (", f_conf_level(conf_level), ")")), n_tot = formatters::with_label("", "Total n"), n_tot_events = formatters::with_label("", "Total events") ) @@ -111,6 +112,9 @@ s_coxph_pairwise <- function(df, pvalue = formatters::with_label(unname(pval), paste0("p-value (", pval_method, ")")), hr = formatters::with_label(sum_cox$conf.int[1, 1], "Hazard Ratio"), hr_ci = formatters::with_label(unname(sum_cox$conf.int[1, 3:4]), f_conf_level(conf_level)), + hr_long = formatters::with_label( + c(sum_cox$conf.int[1, 1], unname(sum_cox$conf.int[1, 3:4])), + paste0("Hazard Ratio (", f_conf_level(conf_level), ")")), n_tot = formatters::with_label(sum_cox$n, "Total n"), n_tot_events = formatters::with_label(sum_cox$nevent, "Total events") ) @@ -124,11 +128,12 @@ s_coxph_pairwise <- function(df, #' @keywords internal a_coxph_pairwise <- make_afun( s_coxph_pairwise, - .indent_mods = c(pvalue = 0L, hr = 0L, hr_ci = 1L, n_tot = 0L, n_tot_events = 0L), + .indent_mods = c(pvalue = 0L, hr = 0L, hr_ci = 1L, n_tot = 0L, n_tot_events = 0L, hr_long = 0L), .formats = c( pvalue = "x.xxxx | (<0.0001)", hr = "xx.xx", hr_ci = "(xx.xx, xx.xx)", + hr_long = "xx.xx (xx.xx - xx.xx)", n_tot = "xx.xx", n_tot_events = "xx.xx" ) diff --git a/R/survival_time.R b/R/survival_time.R index c12f9f489e..8a7a99aed0 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -43,7 +43,10 @@ NULL #' * `s_surv_time()` returns the statistics: #' * `median`: Median survival time. #' * `median_ci`: Confidence interval for median time. +#' * `median_long`: Median with Confidence interval for median time. #' * `quantiles`: Survival time for two specified quantiles. +#' * `quantiles_lower`: quantile with confidence interval for the first specified quantile. +#' * `quantiles_upper`: quantile with confidence interval for the second specified quantile. #' * `range_censor`: Survival time range for censored observations. #' * `range_event`: Survival time range for observations with events. #' * `range`: Survival time range for all observations. @@ -99,15 +102,15 @@ s_surv_time <- function(df, range_censor = formatters::with_label(range_censor, "Range (censored)"), range_event = formatters::with_label(range_event, "Range (event)"), range = formatters::with_label(range, "Range"), - median_ci_1_line = formatters::with_label( + median_long = formatters::with_label( c(unname(srv_tab["median"]), unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), - paste0("Median ", f_conf_level(conf_level))), - quantiles_ci_1 = formatters::with_label( - unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile with ", f_conf_level(conf_level)) + paste0("Median (", f_conf_level(conf_level), ")")), + quantiles_lower = formatters::with_label( + unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile (", f_conf_level(conf_level), ")") ), - quantiles_ci_2 = formatters::with_label( - unname(srv_qt_ci[[2]]), paste0(quantiles[2] * 100, "%-ile with ", f_conf_level(conf_level)) + quantiles_upper = formatters::with_label( + unname(srv_qt_ci[[2]]), paste0(quantiles[2] * 100, "%-ile (", f_conf_level(conf_level), ")") ) ) } @@ -147,14 +150,14 @@ a_surv_time <- function(df, # Use method-specific defaults fmts <- c( median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x", - median_ci_1_line = "xx.x (xx.x - xx.x)", - quantiles_ci_1 = "xx.x (xx.x - xx.x)", quantiles_ci_2 = "xx.x (xx.x - xx.x)" + median_long = "xx.x (xx.x - xx.x)", + quantiles_lower = "xx.x (xx.x - xx.x)", quantiles_upper = "xx.x (xx.x - xx.x)" ) lbls <- c( median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)", - median_ci_1_line = "Median 95% CI", - quantiles_ci_1 = "25%-ile with 95% CI", - quantiles_ci_2 = "75%-ile with 95% CI" + median_long = "Median (95% CI)", + quantiles_lower = "25%-ile (95% CI)", + quantiles_upper = "75%-ile (95% CI)" ) lbls_custom <- .labels .formats <- c(.formats, fmts[setdiff(names(fmts), names(.formats))]) @@ -188,7 +191,6 @@ a_surv_time <- function(df, .names = .labels, .labels = .labels, .indent_mods = .indent_mods, - .format_na_strs = na_str, .cell_footnotes = cell_fns ) } @@ -231,7 +233,7 @@ surv_time <- function(lyt, .labels = NULL, .indent_mods = c(median_ci = 1L)) { extra_args <- list( - .stats = .stats, .formats = .formats, .labels = .labels, .indent_mods = .indent_mods, na_str = na_str, + .stats = .stats, .formats = .formats, .labels = .labels, .indent_mods = .indent_mods, is_event = is_event, control = control, ref_fn_censor = ref_fn_censor, ... ) @@ -242,6 +244,7 @@ surv_time <- function(lyt, var_labels = var_labels, show_labels = show_labels, table_names = table_names, + na_str = na_str, nested = nested, extra_args = extra_args ) diff --git a/R/survival_timepoint.R b/R/survival_timepoint.R index 021e8f2e6d..84b5658c80 100644 --- a/R/survival_timepoint.R +++ b/R/survival_timepoint.R @@ -39,6 +39,7 @@ NULL #' * `event_free_rate`: Event-free rate (%). #' * `rate_se`: Standard error of event free rate. #' * `rate_ci`: Confidence interval for event free rate. +#' * `event_free_rate_long`: Event-free rate (%) with Confidence interval. #' #' @keywords internal s_surv_timepoint <- function(df, @@ -73,11 +74,14 @@ s_surv_timepoint <- function(df, rate_se <- df_srv_fit$std.err rate_ci <- c(df_srv_fit$lower, df_srv_fit$upper) } + event_free_rate_long <- c(event_free_rate, rate_ci) list( pt_at_risk = formatters::with_label(pt_at_risk, "Patients remaining at risk"), event_free_rate = formatters::with_label(event_free_rate * 100, "Event Free Rate (%)"), rate_se = formatters::with_label(rate_se * 100, "Standard Error of Event Free Rate"), - rate_ci = formatters::with_label(rate_ci * 100, f_conf_level(conf_level)) + rate_ci = formatters::with_label(rate_ci * 100, f_conf_level(conf_level)), + event_free_rate_long = formatters::with_label( + event_free_rate_long * 100, paste0("Event Free Rate (", f_conf_level(conf_level), ")")) ) } @@ -110,6 +114,7 @@ a_surv_timepoint <- make_afun( #' * `s_surv_timepoint_diff()` returns the statistics: #' * `rate_diff`: Event-free rate difference between two groups. #' * `rate_diff_ci`: Confidence interval for the difference. +#' * `rate_diff_long`: Event-free rate difference and confidence interval between two groups. #' * `ztest_pval`: p-value to test the difference is 0. #' #' @keywords internal @@ -125,6 +130,8 @@ s_surv_timepoint_diff <- function(df, list( rate_diff = formatters::with_label("", "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label("", f_conf_level(control$conf_level)), + rate_diff_long = formatters::with_label( + "", paste0("Difference in Event Free Rate", f_conf_level(control$conf_level))), ztest_pval = formatters::with_label("", "p-value (Z-test)") ) ) @@ -142,6 +149,7 @@ s_surv_timepoint_diff <- function(df, qs <- c(-1, 1) * stats::qnorm(1 - (1 - control$conf_level) / 2) rate_diff_ci <- rate_diff + qs * se_diff + rate_diff_long <- c(rate_diff, rate_diff_ci) ztest_pval <- if (is.na(rate_diff)) { NA } else { @@ -150,6 +158,8 @@ s_surv_timepoint_diff <- function(df, list( rate_diff = formatters::with_label(rate_diff, "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label(rate_diff_ci, f_conf_level(control$conf_level)), + rate_diff_long = formatters::with_label( + rate_diff_long, paste0("Difference in Event Free Rate", f_conf_level(control$conf_level))), ztest_pval = formatters::with_label(ztest_pval, "p-value (Z-test)") ) } @@ -166,6 +176,7 @@ a_surv_timepoint_diff <- make_afun( .formats = c( rate_diff = "xx.xx", rate_diff_ci = "(xx.xx, xx.xx)", + rate_diff_long = format_xx("xx.xx (xx.xx, xx.xx)"), ztest_pval = "x.xxxx | (<0.0001)" ) ) @@ -259,8 +270,8 @@ surv_timepoint <- function(lyt, extra_args <- list(time_point = time_point, is_event = is_event, control = control, ...) f <- list( - surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci"), - surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval") + surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "event_free_rate_long"), + surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval", "rate_diff_long") ) .stats <- h_split_param(.stats, .stats, f = f) .formats <- h_split_param(.formats, names(.formats), f = f) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index bef5407352..67a9332fd8 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -344,18 +344,18 @@ labels_use_control <- function(labels_default, control, labels_custom = NULL) { labels_default["quantiles"] ) } - if ("quantiles" %in% names(control) && "quantiles_ci_1" %in% names(labels_default) && - !"quantiles_ci_1" %in% names(labels_custom)) { # nolint - labels_default["quantiles_ci_1"] <- gsub( + if ("quantiles" %in% names(control) && "quantiles_lower" %in% names(labels_default) && + !"quantiles_lower" %in% names(labels_custom)) { # nolint + labels_default["quantiles_lower"] <- gsub( "[0-9]+%-ile", paste0(control[["quantiles"]][1] * 100, "%-ile", ""), - labels_default["quantiles_ci_1"] + labels_default["quantiles_lower"] ) } - if ("quantiles" %in% names(control) && "quantiles_ci_2" %in% names(labels_default) && - !"quantiles_ci_2" %in% names(labels_custom)) { # nolint - labels_default["quantiles_ci_2"] <- gsub( + if ("quantiles" %in% names(control) && "quantiles_upper" %in% names(labels_default) && + !"quantiles_upper" %in% names(labels_custom)) { # nolint + labels_default["quantiles_upper"] <- gsub( "[0-9]+%-ile", paste0(control[["quantiles"]][2] * 100, "%-ile", ""), - labels_default["quantiles_ci_2"] + labels_default["quantiles_upper"] ) } if ("test_mean" %in% names(control) && "mean_pval" %in% names(labels_default) && @@ -386,7 +386,8 @@ tern_default_stats <- list( analyze_vars_numeric = c( "n", "sum", "mean", "sd", "se", "mean_sd", "mean_se", "mean_ci", "mean_sei", "mean_sdi", "mean_pval", "median", "mad", "median_ci", "quantiles", "iqr", "range", "min", "max", "median_range", "cv", - "geom_mean", "geom_mean_ci", "geom_cv" + "geom_mean", "geom_mean_ci", "geom_cv", + "mean_long", "median_long", "geom_mean_long" ), count_cumulative = c("count_fraction", "count_fraction_fixed_dp"), count_missed_doses = c("n", "count_fraction", "count_fraction_fixed_dp"), @@ -407,9 +408,11 @@ tern_default_stats <- list( summarize_num_patients = c("unique", "nonunique", "unique_count"), summarize_patients_events_in_cols = c("unique", "all"), surv_time = c( - "median", "median_ci", "median_ci_1_line", "quantiles", - "quantiles_ci_1", "quantiles_ci_2", "range_censor", "range_event", "range"), - surv_timepoint = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval"), + "median", "median_ci", "median_long", "quantiles", + "quantiles_lower", "quantiles_upper", "range_censor", "range_event", "range"), + surv_timepoint = c( + "pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval", + "event_free_rate_long"), tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), tabulate_survival_biomarkers = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), @@ -447,10 +450,10 @@ tern_default_formats <- c( median = "xx.x", mad = "xx.x", median_ci = "(xx.xx, xx.xx)", - median_ci_1_line = "xx.xx (xx.xx, xx.xx)", + median_long = "xx.xx (xx.xx - xx.xx)", quantiles = "xx.x - xx.x", - quantiles_ci_1 = "xx.xx (xx.xx, xx.xx)", - quantiles_ci_2 = "xx.xx (xx.xx, xx.xx)", + quantiles_lower = "xx.xx (xx.xx - xx.xx)", + quantiles_upper = "xx.xx (xx.xx - xx.xx)", iqr = "xx.x", range = "xx.x - xx.x", min = "xx.x", @@ -499,10 +502,10 @@ tern_default_labels <- c( median = "Median", mad = "Median Absolute Deviation", median_ci = "Median 95% CI", - median_ci_1_line = "Median 95% CI", + median_long = "Median (95% CI)", quantiles = "25% and 75%-ile", - quantiles_ci_1 = "25%-ile 95% CI", - quantiles_ci_2 = "75%-ile 95% CI", + quantiles_lower = "25%-ile (95% CI)", + quantiles_upper = "75%-ile (95% CI)", iqr = "IQR", range = "Min - Max", min = "Minimum", diff --git a/tests/testthat/_snaps/survival_coxph_pairwise.md b/tests/testthat/_snaps/survival_coxph_pairwise.md index 282ac2e850..3c81dbda37 100644 --- a/tests/testthat/_snaps/survival_coxph_pairwise.md +++ b/tests/testthat/_snaps/survival_coxph_pairwise.md @@ -18,6 +18,11 @@ attr(,"label") [1] "95% CI" + $hr_long + [1] 0.7108557 0.4779138 1.0573368 + attr(,"label") + [1] "Hazard Ratio (95% CI)" + $n_tot [1] 142 attr(,"label") @@ -49,6 +54,11 @@ attr(,"label") [1] "90% CI" + $hr_long + [1] 0.7108557 0.5094153 0.9919525 + attr(,"label") + [1] "Hazard Ratio (90% CI)" + $n_tot [1] 142 attr(,"label") @@ -80,6 +90,11 @@ attr(,"label") [1] "95% CI" + $hr_long + [1] 0.6251817 0.4014842 0.9735181 + attr(,"label") + [1] "Hazard Ratio (95% CI)" + $n_tot [1] 142 attr(,"label") @@ -111,6 +126,11 @@ attr(,"label") [1] "90% CI" + $hr_long + [1] 0.6251817 0.4311132 0.9066115 + attr(,"label") + [1] "Hazard Ratio (90% CI)" + $n_tot [1] 142 attr(,"label") diff --git a/tests/testthat/_snaps/survival_time.md b/tests/testthat/_snaps/survival_time.md index 0405f2bbe7..dad2784e94 100644 --- a/tests/testthat/_snaps/survival_time.md +++ b/tests/testthat/_snaps/survival_time.md @@ -33,20 +33,20 @@ attr(,"label") [1] "Range" - $median_ci_1_line + $median_long [1] 23.91143 18.25878 32.85945 attr(,"label") - [1] "Median 95% CI" + [1] "Median (95% CI)" - $quantiles_ci_1 + $quantiles_lower [1] 9.822926 5.628823 16.690121 attr(,"label") - [1] "25%-ile with 95% CI" + [1] "25%-ile (95% CI)" - $quantiles_ci_2 + $quantiles_upper [1] 41.98181 32.85945 53.41445 attr(,"label") - [1] "75%-ile with 95% CI" + [1] "75%-ile (95% CI)" # s_surv_time works with customized arguments @@ -84,20 +84,20 @@ attr(,"label") [1] "Range" - $median_ci_1_line + $median_long [1] 23.91143 13.59124 37.97055 attr(,"label") - [1] "Median 99% CI" + [1] "Median (99% CI)" - $quantiles_ci_1 + $quantiles_lower [1] 6.649204 1.887860 12.771697 attr(,"label") - [1] "20%-ile with 99% CI" + [1] "20%-ile (99% CI)" - $quantiles_ci_2 + $quantiles_upper [1] 51.09487 37.97055 NA attr(,"label") - [1] "80%-ile with 99% CI" + [1] "80%-ile (99% CI)" # a_surv_time works with default arguments @@ -107,16 +107,16 @@ Output RowsVerticalSection (in_rows) object print method: ---------------------------- - row_name formatted_cell indent_mod row_label - 1 Median 24.8 0 Median - 2 95% CI (21.1, 31.3) 0 95% CI - 3 Median 95% CI 24.8 (21.1 - 31.3) 0 Median 95% CI - 4 25% and 75%-ile 10.8, 47.6 0 25% and 75%-ile - 5 25%-ile with 95% CI 10.8 (6.6 - 13.4) 0 25%-ile with 95% CI - 6 75%-ile with 95% CI 47.6 (39.3 - 57.8) 0 75%-ile with 95% CI - 7 Range (censored) 0.8 to 78.9 0 Range (censored) - 8 Range (event) 0.1 to 155.5 0 Range (event) - 9 Range 0.1 to 155.5 0 Range + row_name formatted_cell indent_mod row_label + 1 Median 24.8 0 Median + 2 95% CI (21.1, 31.3) 0 95% CI + 3 Median (95% CI) 24.8 (21.1 - 31.3) 0 Median (95% CI) + 4 25% and 75%-ile 10.8, 47.6 0 25% and 75%-ile + 5 25%-ile (95% CI) 10.8 (6.6 - 13.4) 0 25%-ile (95% CI) + 6 75%-ile (95% CI) 47.6 (39.3 - 57.8) 0 75%-ile (95% CI) + 7 Range (censored) 0.8 to 78.9 0 Range (censored) + 8 Range (event) 0.1 to 155.5 0 Range (event) + 9 Range 0.1 to 155.5 0 Range # a_surv_time works with customized arguments @@ -153,10 +153,10 @@ Survival Time (Months) Median 32.0 23.9 20.8 90% CI (25.6, 49.3) (18.9, 32.1) (13.0, 26.0) - Median 90% CI 32.0 (25.6 - 49.3) 23.9 (18.9 - 32.1) 20.8 (13.0 - 26.0) + Median (90% CI) 32.0 (25.6 - 49.3) 23.9 (18.9 - 32.1) 20.8 (13.0 - 26.0) 40% and 60%-ile 25.6, 46.5 18.3, 29.2 13.0, 25.7 - 40%-ile with 90% CI 25.6 (20.7 - 33.4) 18.3 (12.8 - 23.9) 13.0 (10.1 - 24.8) - 60%-ile with 90% CI 46.5 (32.0 - 57.8) 29.2 (23.9 - 41.3) 25.7 (20.8 - 37.1) + 40%-ile (90% CI) 25.6 (20.7 - 33.4) 18.3 (12.8 - 23.9) 13.0 (10.1 - 24.8) + 60%-ile (90% CI) 46.5 (32.0 - 57.8) 29.2 (23.9 - 41.3) 25.7 (20.8 - 37.1) Range (censored) 0.8 to 63.5 6.2 to 78.9 3.4 to 52.4 Range (event) 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 Range 0.3 to 155.5 0.1 to 154.1 0.6 to 80.7 diff --git a/tests/testthat/_snaps/survival_timepoint.md b/tests/testthat/_snaps/survival_timepoint.md index 8c2a7691af..1ca511c166 100644 --- a/tests/testthat/_snaps/survival_timepoint.md +++ b/tests/testthat/_snaps/survival_timepoint.md @@ -23,6 +23,11 @@ attr(,"label") [1] "95% CI" + $event_free_rate_long + [1] 82.19178 73.41549 90.96807 + attr(,"label") + [1] "Event Free Rate (95% CI)" + # s_surv_timepoint works with customized arguments @@ -49,6 +54,11 @@ attr(,"label") [1] "99% CI" + $event_free_rate_long + [1] 75.49797 62.15793 91.70097 + attr(,"label") + [1] "Event Free Rate (99% CI)" + # s_surv_timepoint also works when there are 0 patients at risk @@ -75,6 +85,11 @@ attr(,"label") [1] "95% CI" + $event_free_rate_long + [1] NA NA NA + attr(,"label") + [1] "Event Free Rate (95% CI)" + # surv_timepoint works with default arguments @@ -115,6 +130,11 @@ attr(,"label") [1] "95% CI" + $rate_diff_long + [1] 4.269100 -7.767371 16.305570 + attr(,"label") + [1] "Difference in Event Free Rate95% CI" + $ztest_pval [1] 0.4869546 attr(,"label") @@ -136,6 +156,11 @@ attr(,"label") [1] "90% CI" + $rate_diff_long + [1] 9.640872 -1.404177 20.685921 + attr(,"label") + [1] "Difference in Event Free Rate90% CI" + $ztest_pval [1] 0.1510762 attr(,"label") From 9796d6527171933ba73b542eea2ae6025082738e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:25:35 +0000 Subject: [PATCH 07/10] [skip style] [skip vbump] Restyle files --- R/survival_coxph_pairwise.R | 3 ++- R/survival_time.R | 9 ++++++--- R/survival_timepoint.R | 9 ++++++--- R/utils_default_stats_formats_labels.R | 6 ++++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/R/survival_coxph_pairwise.R b/R/survival_coxph_pairwise.R index be30d237bc..15b056e8be 100644 --- a/R/survival_coxph_pairwise.R +++ b/R/survival_coxph_pairwise.R @@ -114,7 +114,8 @@ s_coxph_pairwise <- function(df, hr_ci = formatters::with_label(unname(sum_cox$conf.int[1, 3:4]), f_conf_level(conf_level)), hr_long = formatters::with_label( c(sum_cox$conf.int[1, 1], unname(sum_cox$conf.int[1, 3:4])), - paste0("Hazard Ratio (", f_conf_level(conf_level), ")")), + paste0("Hazard Ratio (", f_conf_level(conf_level), ")") + ), n_tot = formatters::with_label(sum_cox$n, "Total n"), n_tot_events = formatters::with_label(sum_cox$nevent, "Total events") ) diff --git a/R/survival_time.R b/R/survival_time.R index 221b88fb7f..7acd6bf368 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -103,9 +103,12 @@ s_surv_time <- function(df, range_event = formatters::with_label(range_event, "Range (event)"), range = formatters::with_label(range, "Range"), median_long = formatters::with_label( - c(unname(srv_tab["median"]), - unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))])), - paste0("Median (", f_conf_level(conf_level), ")")), + c( + unname(srv_tab["median"]), + unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))]) + ), + paste0("Median (", f_conf_level(conf_level), ")") + ), quantiles_lower = formatters::with_label( unname(srv_qt_ci[[1]]), paste0(quantiles[1] * 100, "%-ile (", f_conf_level(conf_level), ")") ), diff --git a/R/survival_timepoint.R b/R/survival_timepoint.R index 84b5658c80..95190fcbd8 100644 --- a/R/survival_timepoint.R +++ b/R/survival_timepoint.R @@ -81,7 +81,8 @@ s_surv_timepoint <- function(df, rate_se = formatters::with_label(rate_se * 100, "Standard Error of Event Free Rate"), rate_ci = formatters::with_label(rate_ci * 100, f_conf_level(conf_level)), event_free_rate_long = formatters::with_label( - event_free_rate_long * 100, paste0("Event Free Rate (", f_conf_level(conf_level), ")")) + event_free_rate_long * 100, paste0("Event Free Rate (", f_conf_level(conf_level), ")") + ) ) } @@ -131,7 +132,8 @@ s_surv_timepoint_diff <- function(df, rate_diff = formatters::with_label("", "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label("", f_conf_level(control$conf_level)), rate_diff_long = formatters::with_label( - "", paste0("Difference in Event Free Rate", f_conf_level(control$conf_level))), + "", paste0("Difference in Event Free Rate", f_conf_level(control$conf_level)) + ), ztest_pval = formatters::with_label("", "p-value (Z-test)") ) ) @@ -159,7 +161,8 @@ s_surv_timepoint_diff <- function(df, rate_diff = formatters::with_label(rate_diff, "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label(rate_diff_ci, f_conf_level(control$conf_level)), rate_diff_long = formatters::with_label( - rate_diff_long, paste0("Difference in Event Free Rate", f_conf_level(control$conf_level))), + rate_diff_long, paste0("Difference in Event Free Rate", f_conf_level(control$conf_level)) + ), ztest_pval = formatters::with_label(ztest_pval, "p-value (Z-test)") ) } diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 67a9332fd8..5cec08d0b8 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -409,10 +409,12 @@ tern_default_stats <- list( summarize_patients_events_in_cols = c("unique", "all"), surv_time = c( "median", "median_ci", "median_long", "quantiles", - "quantiles_lower", "quantiles_upper", "range_censor", "range_event", "range"), + "quantiles_lower", "quantiles_upper", "range_censor", "range_event", "range" + ), surv_timepoint = c( "pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval", - "event_free_rate_long"), + "event_free_rate_long" + ), tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), tabulate_survival_biomarkers = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), From eeff6633e7e03a9fbae242300ba196bb918b9bfe Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:29:52 +0000 Subject: [PATCH 08/10] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/survival_time.Rd | 3 +++ man/survival_timepoint.Rd | 2 ++ 2 files changed, 5 insertions(+) diff --git a/man/survival_time.Rd b/man/survival_time.Rd index 6b658b0e3d..66e26c9f61 100644 --- a/man/survival_time.Rd +++ b/man/survival_time.Rd @@ -111,7 +111,10 @@ the statistics from \code{s_surv_time()} to the table layout. \itemize{ \item \code{median}: Median survival time. \item \code{median_ci}: Confidence interval for median time. +\item \code{median_long}: Median with confidence interval for median time. \item \code{quantiles}: Survival time for two specified quantiles. +\item \code{quantiles_lower}: quantile with confidence interval for the first specified quantile. +\item \code{quantiles_upper}: quantile with confidence interval for the second specified quantile. \item \code{range_censor}: Survival time range for censored observations. \item \code{range_event}: Survival time range for observations with events. \item \code{range}: Survival time range for all observations. diff --git a/man/survival_timepoint.Rd b/man/survival_timepoint.Rd index e6cbeb22e2..1addc05440 100644 --- a/man/survival_timepoint.Rd +++ b/man/survival_timepoint.Rd @@ -141,6 +141,7 @@ the value of \code{method}. \item \code{event_free_rate}: Event-free rate (\%). \item \code{rate_se}: Standard error of event free rate. \item \code{rate_ci}: Confidence interval for event free rate. +\item \code{event_free_rate_long}: Event-free rate (\%) with Confidence interval. } } @@ -153,6 +154,7 @@ the value of \code{method}. \itemize{ \item \code{rate_diff}: Event-free rate difference between two groups. \item \code{rate_diff_ci}: Confidence interval for the difference. +\item \code{rate_diff_long}: Event-free rate difference and confidence interval between two groups. \item \code{ztest_pval}: p-value to test the difference is 0. } } From 4976bb5dccec07ae5af250291587384215cd51a3 Mon Sep 17 00:00:00 2001 From: Ilse Augustyns Date: Fri, 27 Sep 2024 10:01:00 +0000 Subject: [PATCH 09/10] updates for snapshots + add long version of stats (mean, median, geom_mean) to s_summary.numeric --- R/analyze_variables.R | 8 + R/utils_default_stats_formats_labels.R | 7 +- tests/testthat/_snaps/analyze_variables.md | 198 +++++++++++++----- tests/testthat/_snaps/compare_variables.md | 12 +- tests/testthat/_snaps/summarize_change.md | 72 +++++++ .../utils_default_stats_formats_labels.md | 50 +++-- tests/testthat/test-utils_rtables.R | 1 + 7 files changed, 270 insertions(+), 78 deletions(-) diff --git a/R/analyze_variables.R b/R/analyze_variables.R index 69e0041607..d54aa0bac0 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -188,6 +188,8 @@ s_summary.numeric <- function(x, mean_sdi <- y$mean[[1]] + c(-1, 1) * stats::sd(x, na.rm = FALSE) names(mean_sdi) <- c("mean_sdi_lwr", "mean_sdi_upr") y$mean_sdi <- formatters::with_label(mean_sdi, "Mean -/+ 1xSD") + mean_long <- c(y$mean, y$mean_ci) + y$mean_long <- formatters::with_label(mean_long, paste0("Mean (", f_conf_level(control$conf_level), ")")) mean_pval <- stat_mean_pval(x, test_mean = control$test_mean, na.rm = FALSE, n_min = 2) y$mean_pval <- formatters::with_label(mean_pval, paste("Mean", f_pval(control$test_mean))) @@ -199,6 +201,9 @@ s_summary.numeric <- function(x, median_ci <- stat_median_ci(x, conf_level = control$conf_level, na.rm = FALSE, gg_helper = FALSE) y$median_ci <- formatters::with_label(median_ci, paste("Median", f_conf_level(control$conf_level))) + median_long <- c(y$median, median_ci) + y$median_long <- formatters::with_label(median_long, paste0("Median (", f_conf_level(control$conf_level), ")")) + q <- control$quantiles if (any(is.na(x))) { qnts <- rep(NA_real_, length(q)) @@ -231,6 +236,9 @@ s_summary.numeric <- function(x, y$geom_cv <- c("geom_cv" = sqrt(exp(stats::sd(log(x_no_negative_vals), na.rm = FALSE) ^ 2) - 1) * 100) # styler: off + geom_mean_long <- c(y$geom_mean, y$geom_mean_ci) + y$geom_mean_long <- formatters::with_label(geom_mean_long, paste0("Geometric Mean (", f_conf_level(control$conf_level), ")")) + y } diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 5524ec2445..0411e32251 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -387,7 +387,8 @@ tern_default_stats <- list( "n", "sum", "mean", "sd", "se", "mean_sd", "mean_se", "mean_ci", "mean_sei", "mean_sdi", "mean_pval", "median", "mad", "median_ci", "quantiles", "iqr", "range", "min", "max", "median_range", "cv", "geom_mean", "geom_mean_ci", "geom_cv", - "mean_long", "median_long", "geom_mean_long" + "median_long", + "mean_long", "geom_mean_long" ), count_cumulative = c("count_fraction", "count_fraction_fixed_dp"), count_missed_doses = c("n", "count_fraction", "count_fraction_fixed_dp"), @@ -449,6 +450,7 @@ tern_default_formats <- c( mean_sei = "(xx.xx, xx.xx)", mean_sdi = "(xx.xx, xx.xx)", mean_pval = "x.xxxx | (<0.0001)", + mean_long = "xx.xx (xx.xx - xx.xx)", median = "xx.x", mad = "xx.x", median_ci = "(xx.xx, xx.xx)", @@ -464,6 +466,7 @@ tern_default_formats <- c( cv = "xx.x", geom_mean = "xx.x", geom_mean_ci = "(xx.xx, xx.xx)", + geom_mean_long = "xx.xx (xx.xx - xx.xx)", geom_cv = "xx.x", pval = "x.xxxx | (<0.0001)", pval_counts = "x.xxxx | (<0.0001)", @@ -501,6 +504,7 @@ tern_default_labels <- c( mean_sei = "Mean -/+ 1xSE", mean_sdi = "Mean -/+ 1xSD", mean_pval = "Mean p-value (H0: mean = 0)", + mean_long = "Mean (95% CI)", median = "Median", mad = "Median Absolute Deviation", median_ci = "Median 95% CI", @@ -516,6 +520,7 @@ tern_default_labels <- c( cv = "CV (%)", geom_mean = "Geometric Mean", geom_mean_ci = "Geometric Mean 95% CI", + geom_mean_long = "Geometric Mean (95% CI)", geom_cv = "CV % Geometric Mean", pval = "p-value (t-test)", # Default for numeric pval_counts = "p-value (chi-squared test)", # Default for counts diff --git a/tests/testthat/_snaps/analyze_variables.md b/tests/testthat/_snaps/analyze_variables.md index 65f42acee6..dc064755f7 100644 --- a/tests/testthat/_snaps/analyze_variables.md +++ b/tests/testthat/_snaps/analyze_variables.md @@ -49,6 +49,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_long + mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -71,6 +77,12 @@ attr(,"label") [1] "Median 95% CI" + $median_long + median median_ci_lwr median_ci_upr + NA NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 NA NA @@ -117,6 +129,12 @@ geom_cv NA + $geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + NaN NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary handles NA @@ -169,6 +187,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_long + mean mean_ci_lwr mean_ci_upr + 1 NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -191,6 +215,12 @@ attr(,"label") [1] "Median 95% CI" + $median_long + median median_ci_lwr median_ci_upr + 1 NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 1 1 @@ -237,6 +267,12 @@ geom_cv NA + $geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + 1 NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + --- @@ -289,6 +325,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_long + mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -311,6 +353,12 @@ attr(,"label") [1] "Median 95% CI" + $median_long + median median_ci_lwr median_ci_upr + NA NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 NA NA @@ -357,6 +405,12 @@ geom_cv NA + $geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary returns right results for n = 2 @@ -409,6 +463,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_long + mean mean_ci_lwr mean_ci_upr + 1.500000 -4.853102 7.853102 + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value 0.2048328 @@ -431,6 +491,12 @@ attr(,"label") [1] "Median 95% CI" + $median_long + median median_ci_lwr median_ci_upr + 1.5 NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 1 2 @@ -477,6 +543,12 @@ geom_cv 52.10922 + $geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + 1.41421356 0.01729978 115.60839614 + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary returns right results for n = 8 @@ -529,6 +601,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_long + mean mean_ci_lwr mean_ci_upr + 6.000000 3.318768 8.681232 + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value 0.001133783 @@ -551,6 +629,12 @@ attr(,"label") [1] "Median 95% CI" + $median_long + median median_ci_lwr median_ci_upr + 6.5 1.0 10.0 + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 3.5 8.5 @@ -597,6 +681,12 @@ geom_cv 96.61307 + $geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + 4.842534 2.456211 9.547283 + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_summary works with factors @@ -1033,31 +1123,34 @@ Output RowsVerticalSection (in_rows) object print method: ---------------------------- - row_name formatted_cell indent_mod row_label - 1 n 10 0 n - 2 Sum 1.3 0 Sum - 3 Mean 0.1 0 Mean - 4 SD 0.8 0 SD - 5 SE 0.2 0 SE - 6 Mean (SD) 0.1 (0.8) 0 Mean (SD) - 7 Mean (SE) 0.1 (0.2) 0 Mean (SE) - 8 Mean 95% CI (-0.43, 0.69) 0 Mean 95% CI - 9 Mean -/+ 1xSE (-0.11, 0.38) 0 Mean -/+ 1xSE - 10 Mean -/+ 1xSD (-0.65, 0.91) 0 Mean -/+ 1xSD - 11 Mean p-value (H0: mean = 0) 0.6052 0 Mean p-value (H0: mean = 0) - 12 Median 0.3 0 Median - 13 Median Absolute Deviation -0.0 0 Median Absolute Deviation - 14 Median 95% CI (-0.82, 0.74) 0 Median 95% CI - 15 25% and 75%-ile -0.6 - 0.6 0 25% and 75%-ile - 16 IQR 1.2 0 IQR - 17 Min - Max -0.8 - 1.6 0 Min - Max - 18 Minimum -0.8 0 Minimum - 19 Maximum 1.6 0 Maximum - 20 Median (Min - Max) 0.3 (-0.8 - 1.6) 0 Median (Min - Max) - 21 CV (%) 590.4 0 CV (%) - 22 Geometric Mean NA 0 Geometric Mean - 23 Geometric Mean 95% CI NA 0 Geometric Mean 95% CI - 24 CV % Geometric Mean NA 0 CV % Geometric Mean + row_name formatted_cell indent_mod row_label + 1 n 10 0 n + 2 Sum 1.3 0 Sum + 3 Mean 0.1 0 Mean + 4 SD 0.8 0 SD + 5 SE 0.2 0 SE + 6 Mean (SD) 0.1 (0.8) 0 Mean (SD) + 7 Mean (SE) 0.1 (0.2) 0 Mean (SE) + 8 Mean 95% CI (-0.43, 0.69) 0 Mean 95% CI + 9 Mean -/+ 1xSE (-0.11, 0.38) 0 Mean -/+ 1xSE + 10 Mean -/+ 1xSD (-0.65, 0.91) 0 Mean -/+ 1xSD + 11 Mean p-value (H0: mean = 0) 0.6052 0 Mean p-value (H0: mean = 0) + 12 Median 0.3 0 Median + 13 Median Absolute Deviation -0.0 0 Median Absolute Deviation + 14 Median 95% CI (-0.82, 0.74) 0 Median 95% CI + 15 25% and 75%-ile -0.6 - 0.6 0 25% and 75%-ile + 16 IQR 1.2 0 IQR + 17 Min - Max -0.8 - 1.6 0 Min - Max + 18 Minimum -0.8 0 Minimum + 19 Maximum 1.6 0 Maximum + 20 Median (Min - Max) 0.3 (-0.8 - 1.6) 0 Median (Min - Max) + 21 CV (%) 590.4 0 CV (%) + 22 Geometric Mean NA 0 Geometric Mean + 23 Geometric Mean 95% CI NA 0 Geometric Mean 95% CI + 24 CV % Geometric Mean NA 0 CV % Geometric Mean + 25 Median (95% CI) 0.26 (-0.82 - 0.74) 0 Median (95% CI) + 26 Mean (95% CI) 0.13 (-0.43 - 0.69) 0 Mean (95% CI) + 27 Geometric Mean (95% CI) NA 0 Geometric Mean (95% CI) --- @@ -1165,32 +1258,35 @@ Output RowsVerticalSection (in_rows) object print method: ---------------------------- - row_name formatted_cell indent_mod row_label - 1 n 10 0 n - 2 Sum 51.3 0 Sum - 3 Mean 5.1 0 Mean - 4 SD 0.8 0 SD - 5 SE 0.2 0 SE - 6 Mean (SD) 5.1 (0.8) 0 Mean (SD) - 7 Mean (SE) 5.1 (0.2) 0 Mean (SE) - 8 Mean 95% CI (4.57, 5.69) 0 Mean 95% CI - 9 Mean -/+ 1xSE (4.89, 5.38) 0 Mean -/+ 1xSE - 10 Mean -/+ 1xSD (4.35, 5.91) 0 Mean -/+ 1xSD - 11 Mean p-value (H0: mean = 0) <0.0001 0 Mean p-value (H0: mean = 0) - 12 Median 5.3 0 Median - 13 Median Absolute Deviation -0.0 0 Median Absolute Deviation - 14 Median 95% CI (4.18, 5.74) 0 Median 95% CI - 15 25% and 75%-ile 4.4 - 5.6 0 25% and 75%-ile - 16 IQR 1.2 0 IQR - 17 Min - Max 4.2 - 6.6 0 Min - Max - 18 Minimum 4.2 0 Minimum - 19 Maximum 6.6 0 Maximum - 20 Median (Min - Max) 5.3 (4.2 - 6.6) 0 Median (Min - Max) - 21 CV (%) 15.2 0 CV (%) - 22 Geometric Mean 5.1 0 Geometric Mean - 23 Geometric Mean 95% CI (4.56, 5.66) 0 Geometric Mean 95% CI - 24 CV % Geometric Mean 15.2 0 CV % Geometric Mean - 25 p-value (t-test) <0.0001 0 p-value (t-test) + row_name formatted_cell indent_mod row_label + 1 n 10 0 n + 2 Sum 51.3 0 Sum + 3 Mean 5.1 0 Mean + 4 SD 0.8 0 SD + 5 SE 0.2 0 SE + 6 Mean (SD) 5.1 (0.8) 0 Mean (SD) + 7 Mean (SE) 5.1 (0.2) 0 Mean (SE) + 8 Mean 95% CI (4.57, 5.69) 0 Mean 95% CI + 9 Mean -/+ 1xSE (4.89, 5.38) 0 Mean -/+ 1xSE + 10 Mean -/+ 1xSD (4.35, 5.91) 0 Mean -/+ 1xSD + 11 Mean p-value (H0: mean = 0) <0.0001 0 Mean p-value (H0: mean = 0) + 12 Median 5.3 0 Median + 13 Median Absolute Deviation -0.0 0 Median Absolute Deviation + 14 Median 95% CI (4.18, 5.74) 0 Median 95% CI + 15 25% and 75%-ile 4.4 - 5.6 0 25% and 75%-ile + 16 IQR 1.2 0 IQR + 17 Min - Max 4.2 - 6.6 0 Min - Max + 18 Minimum 4.2 0 Minimum + 19 Maximum 6.6 0 Maximum + 20 Median (Min - Max) 5.3 (4.2 - 6.6) 0 Median (Min - Max) + 21 CV (%) 15.2 0 CV (%) + 22 Geometric Mean 5.1 0 Geometric Mean + 23 Geometric Mean 95% CI (4.56, 5.66) 0 Geometric Mean 95% CI + 24 CV % Geometric Mean 15.2 0 CV % Geometric Mean + 25 Median (95% CI) 5.26 (4.18 - 5.74) 0 Median (95% CI) + 26 Mean (95% CI) 5.13 (4.57 - 5.69) 0 Mean (95% CI) + 27 Geometric Mean (95% CI) 5.08 (4.56 - 5.66) 0 Geometric Mean (95% CI) + 28 p-value (t-test) <0.0001 0 p-value (t-test) --- diff --git a/tests/testthat/_snaps/compare_variables.md b/tests/testthat/_snaps/compare_variables.md index 493db5697c..0cacb94c3c 100644 --- a/tests/testthat/_snaps/compare_variables.md +++ b/tests/testthat/_snaps/compare_variables.md @@ -3,11 +3,13 @@ Code res Output - [1] "n" "sum" "mean" "sd" "se" - [6] "mean_sd" "mean_se" "mean_ci" "mean_sei" "mean_sdi" - [11] "mean_pval" "median" "mad" "median_ci" "quantiles" - [16] "iqr" "range" "min" "max" "median_range" - [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" "pval" + [1] "n" "sum" "mean" "sd" + [5] "se" "mean_sd" "mean_se" "mean_ci" + [9] "mean_sei" "mean_sdi" "mean_long" "mean_pval" + [13] "median" "mad" "median_ci" "median_long" + [17] "quantiles" "iqr" "range" "min" + [21] "max" "median_range" "cv" "geom_mean" + [25] "geom_mean_ci" "geom_cv" "geom_mean_long" "pval" # s_compare for numeric does not give p-value when not at least 2 values in each group diff --git a/tests/testthat/_snaps/summarize_change.md b/tests/testthat/_snaps/summarize_change.md index b0e8774d89..f46df79af1 100644 --- a/tests/testthat/_snaps/summarize_change.md +++ b/tests/testthat/_snaps/summarize_change.md @@ -49,6 +49,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_long + mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value NA @@ -71,6 +77,12 @@ attr(,"label") [1] "Median 95% CI" + $median_long + median median_ci_lwr median_ci_upr + NA NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 NA NA @@ -117,6 +129,12 @@ geom_cv NA + $geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + NaN NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_change_from_baseline handles NA in baseline values @@ -169,6 +187,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $mean_long + mean mean_ci_lwr mean_ci_upr + 3.000000 -4.452413 10.452413 + attr(,"label") + [1] "Mean (95% CI)" + $mean_pval p_value 0.2254033 @@ -191,6 +215,12 @@ attr(,"label") [1] "Median 95% CI" + $median_long + median median_ci_lwr median_ci_upr + 3 NA NA + attr(,"label") + [1] "Median (95% CI)" + $quantiles quantile_0.25 quantile_0.75 0 6 @@ -237,6 +267,12 @@ geom_cv NA + $geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + NA NA NA + attr(,"label") + [1] "Geometric Mean (95% CI)" + # s_change_from_baseline handles baseline substitution @@ -290,6 +326,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $`FALSE`$mean_long + mean mean_ci_lwr mean_ci_upr + 1.500000 -4.853102 7.853102 + attr(,"label") + [1] "Mean (95% CI)" + $`FALSE`$mean_pval p_value 0.2048328 @@ -312,6 +354,12 @@ attr(,"label") [1] "Median 95% CI" + $`FALSE`$median_long + median median_ci_lwr median_ci_upr + 1.5 NA NA + attr(,"label") + [1] "Median (95% CI)" + $`FALSE`$quantiles quantile_0.25 quantile_0.75 1 2 @@ -358,6 +406,12 @@ geom_cv 52.10922 + $`FALSE`$geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + 1.41421356 0.01729978 115.60839614 + attr(,"label") + [1] "Geometric Mean (95% CI)" + $`TRUE` $`TRUE`$n @@ -406,6 +460,12 @@ attr(,"label") [1] "Mean -/+ 1xSD" + $`TRUE`$mean_long + mean mean_ci_lwr mean_ci_upr + 2.50000 -16.55931 21.55931 + attr(,"label") + [1] "Mean (95% CI)" + $`TRUE`$mean_pval p_value 0.3440417 @@ -428,6 +488,12 @@ attr(,"label") [1] "Median 95% CI" + $`TRUE`$median_long + median median_ci_lwr median_ci_upr + 2.5 NA NA + attr(,"label") + [1] "Median (95% CI)" + $`TRUE`$quantiles quantile_0.25 quantile_0.75 1 4 @@ -474,6 +540,12 @@ geom_cv 127.0458 + $`TRUE`$geom_mean_long + geom_mean mean_ci_lwr mean_ci_upr + 2.000000e+00 2.992824e-04 1.336530e+04 + attr(,"label") + [1] "Geometric Mean (95% CI)" + # summarize_change works as expected diff --git a/tests/testthat/_snaps/utils_default_stats_formats_labels.md b/tests/testthat/_snaps/utils_default_stats_formats_labels.md index 774a14a31d..ea57d3c8a2 100644 --- a/tests/testthat/_snaps/utils_default_stats_formats_labels.md +++ b/tests/testthat/_snaps/utils_default_stats_formats_labels.md @@ -27,11 +27,13 @@ Code res Output - [1] "n" "sum" "mean" "sd" "se" - [6] "mean_sd" "mean_se" "mean_ci" "mean_sei" "mean_sdi" - [11] "mean_pval" "median" "mad" "median_ci" "quantiles" - [16] "iqr" "range" "min" "max" "median_range" - [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" + [1] "n" "sum" "mean" "sd" + [5] "se" "mean_sd" "mean_se" "mean_ci" + [9] "mean_sei" "mean_sdi" "mean_pval" "median" + [13] "mad" "median_ci" "quantiles" "iqr" + [17] "range" "min" "max" "median_range" + [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" + [25] "median_long" "mean_long" "geom_mean_long" # get_labels_from_stats works as expected @@ -82,22 +84,24 @@ Code res Output - n sum mean - "xx." "xx.x" "xx.x" - sd se mean_sd - "xx.x" "xx.x" "xx.x (xx.x)" - mean_se mean_ci mean_sei - "xx.x (xx.x)" "(xx.xx, xx.xx)" "(xx.xx, xx.xx)" - mean_sdi mean_pval median - "(xx.xx, xx.xx)" "x.xxxx | (<0.0001)" "xx.x" - mad median_ci quantiles - "xx.x" "(xx.xx, xx.xx)" "xx.x - xx.x" - iqr range min - "xx.x" "xx.x - xx.x" "xx.x" - max median_range cv - "xx.x" "xx.x (xx.x - xx.x)" "xx.x" - geom_mean geom_mean_ci geom_cv - "xx.x" "(xx.xx, xx.xx)" "xx.x" + n sum mean + "xx." "xx.x" "xx.x" + sd se mean_sd + "xx.x" "xx.x" "xx.x (xx.x)" + mean_se mean_ci mean_sei + "xx.x (xx.x)" "(xx.xx, xx.xx)" "(xx.xx, xx.xx)" + mean_sdi mean_pval median + "(xx.xx, xx.xx)" "x.xxxx | (<0.0001)" "xx.x" + mad median_ci quantiles + "xx.x" "(xx.xx, xx.xx)" "xx.x - xx.x" + iqr range min + "xx.x" "xx.x - xx.x" "xx.x" + max median_range cv + "xx.x" "xx.x (xx.x - xx.x)" "xx.x" + geom_mean geom_mean_ci geom_cv + "xx.x" "(xx.xx, xx.xx)" "xx.x" + median_long mean_long geom_mean_long + "xx.xx (xx.xx - xx.xx)" "xx.xx (xx.xx - xx.xx)" "xx.xx (xx.xx - xx.xx)" # summary_labels works as expected @@ -128,6 +132,10 @@ "CV (%)" "Geometric Mean" geom_mean_ci geom_cv "Geometric Mean 95% CI" "CV % Geometric Mean" + median_long mean_long + "Median (95% CI)" "Mean (95% CI)" + geom_mean_long + "Geometric Mean (95% CI)" --- diff --git a/tests/testthat/test-utils_rtables.R b/tests/testthat/test-utils_rtables.R index 3e482c9a39..fbeb9e337c 100644 --- a/tests/testthat/test-utils_rtables.R +++ b/tests/testthat/test-utils_rtables.R @@ -291,4 +291,5 @@ testthat::test_that("default na_str works properly", { analyze_vars(vars = "VAR", .stats = c("n", "mean")) %>% build_table(dt) testthat::expect_identical(matrix_form(tbl)$strings[-1, 2], c("0", "")) + set_default_na_str(NULL) }) From 620f068c049acfafa4417a80e09f8e6143835f14 Mon Sep 17 00:00:00 2001 From: Ilse Augustyns Date: Mon, 14 Oct 2024 12:19:00 +0000 Subject: [PATCH 10/10] update name of new stats according to suggestion median_long into median_ci_3d --- R/analyze_variables.R | 12 ++++---- R/survival_coxph_pairwise.R | 8 ++--- R/survival_time.R | 8 ++--- R/survival_timepoint.R | 24 +++++++-------- R/utils_default_stats_formats_labels.R | 20 ++++++------- tests/testthat/_snaps/analyze_variables.md | 30 +++++++++---------- tests/testthat/_snaps/compare_variables.md | 14 ++++----- tests/testthat/_snaps/summarize_change.md | 24 +++++++-------- .../_snaps/survival_coxph_pairwise.md | 8 ++--- tests/testthat/_snaps/survival_time.md | 4 +-- tests/testthat/_snaps/survival_timepoint.md | 10 +++---- .../utils_default_stats_formats_labels.md | 8 ++--- 12 files changed, 85 insertions(+), 85 deletions(-) diff --git a/R/analyze_variables.R b/R/analyze_variables.R index d54aa0bac0..b2dccab158 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -188,8 +188,8 @@ s_summary.numeric <- function(x, mean_sdi <- y$mean[[1]] + c(-1, 1) * stats::sd(x, na.rm = FALSE) names(mean_sdi) <- c("mean_sdi_lwr", "mean_sdi_upr") y$mean_sdi <- formatters::with_label(mean_sdi, "Mean -/+ 1xSD") - mean_long <- c(y$mean, y$mean_ci) - y$mean_long <- formatters::with_label(mean_long, paste0("Mean (", f_conf_level(control$conf_level), ")")) + mean_ci_3d <- c(y$mean, y$mean_ci) + y$mean_ci_3d <- formatters::with_label(mean_ci_3d, paste0("Mean (", f_conf_level(control$conf_level), ")")) mean_pval <- stat_mean_pval(x, test_mean = control$test_mean, na.rm = FALSE, n_min = 2) y$mean_pval <- formatters::with_label(mean_pval, paste("Mean", f_pval(control$test_mean))) @@ -201,8 +201,8 @@ s_summary.numeric <- function(x, median_ci <- stat_median_ci(x, conf_level = control$conf_level, na.rm = FALSE, gg_helper = FALSE) y$median_ci <- formatters::with_label(median_ci, paste("Median", f_conf_level(control$conf_level))) - median_long <- c(y$median, median_ci) - y$median_long <- formatters::with_label(median_long, paste0("Median (", f_conf_level(control$conf_level), ")")) + median_ci_3d <- c(y$median, median_ci) + y$median_ci_3d <- formatters::with_label(median_ci_3d, paste0("Median (", f_conf_level(control$conf_level), ")")) q <- control$quantiles if (any(is.na(x))) { @@ -236,8 +236,8 @@ s_summary.numeric <- function(x, y$geom_cv <- c("geom_cv" = sqrt(exp(stats::sd(log(x_no_negative_vals), na.rm = FALSE) ^ 2) - 1) * 100) # styler: off - geom_mean_long <- c(y$geom_mean, y$geom_mean_ci) - y$geom_mean_long <- formatters::with_label(geom_mean_long, paste0("Geometric Mean (", f_conf_level(control$conf_level), ")")) + geom_mean_ci_3d <- c(y$geom_mean, y$geom_mean_ci) + y$geom_mean_ci_3d <- formatters::with_label(geom_mean_ci_3d, paste0("Geometric Mean (", f_conf_level(control$conf_level), ")")) y } diff --git a/R/survival_coxph_pairwise.R b/R/survival_coxph_pairwise.R index 15b056e8be..98b0fedfd2 100644 --- a/R/survival_coxph_pairwise.R +++ b/R/survival_coxph_pairwise.R @@ -65,7 +65,7 @@ s_coxph_pairwise <- function(df, pvalue = formatters::with_label("", paste0("p-value (", pval_method, ")")), hr = formatters::with_label("", "Hazard Ratio"), hr_ci = formatters::with_label("", f_conf_level(conf_level)), - hr_long = formatters::with_label("", paste0("Hazard Ratio (", f_conf_level(conf_level), ")")), + hr_ci_3d = formatters::with_label("", paste0("Hazard Ratio (", f_conf_level(conf_level), ")")), n_tot = formatters::with_label("", "Total n"), n_tot_events = formatters::with_label("", "Total events") ) @@ -112,7 +112,7 @@ s_coxph_pairwise <- function(df, pvalue = formatters::with_label(unname(pval), paste0("p-value (", pval_method, ")")), hr = formatters::with_label(sum_cox$conf.int[1, 1], "Hazard Ratio"), hr_ci = formatters::with_label(unname(sum_cox$conf.int[1, 3:4]), f_conf_level(conf_level)), - hr_long = formatters::with_label( + hr_ci_3d = formatters::with_label( c(sum_cox$conf.int[1, 1], unname(sum_cox$conf.int[1, 3:4])), paste0("Hazard Ratio (", f_conf_level(conf_level), ")") ), @@ -129,12 +129,12 @@ s_coxph_pairwise <- function(df, #' @keywords internal a_coxph_pairwise <- make_afun( s_coxph_pairwise, - .indent_mods = c(pvalue = 0L, hr = 0L, hr_ci = 1L, n_tot = 0L, n_tot_events = 0L, hr_long = 0L), + .indent_mods = c(pvalue = 0L, hr = 0L, hr_ci = 1L, n_tot = 0L, n_tot_events = 0L, hr_ci_3d = 0L), .formats = c( pvalue = "x.xxxx | (<0.0001)", hr = "xx.xx", hr_ci = "(xx.xx, xx.xx)", - hr_long = "xx.xx (xx.xx - xx.xx)", + hr_ci_3d = "xx.xx (xx.xx - xx.xx)", n_tot = "xx.xx", n_tot_events = "xx.xx" ) diff --git a/R/survival_time.R b/R/survival_time.R index 7acd6bf368..6865d956ef 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -43,7 +43,7 @@ NULL #' * `s_surv_time()` returns the statistics: #' * `median`: Median survival time. #' * `median_ci`: Confidence interval for median time. -#' * `median_long`: Median with confidence interval for median time. +#' * `median_ci_3d`: Median with confidence interval for median time. #' * `quantiles`: Survival time for two specified quantiles. #' * `quantiles_lower`: quantile with confidence interval for the first specified quantile. #' * `quantiles_upper`: quantile with confidence interval for the second specified quantile. @@ -102,7 +102,7 @@ s_surv_time <- function(df, range_censor = formatters::with_label(range_censor, "Range (censored)"), range_event = formatters::with_label(range_event, "Range (event)"), range = formatters::with_label(range, "Range"), - median_long = formatters::with_label( + median_ci_3d = formatters::with_label( c( unname(srv_tab["median"]), unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))]) @@ -153,12 +153,12 @@ a_surv_time <- function(df, # Use method-specific defaults fmts <- c( median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range = "xx.x to xx.x", - median_long = "xx.x (xx.x - xx.x)", + median_ci_3d = "xx.x (xx.x - xx.x)", quantiles_lower = "xx.x (xx.x - xx.x)", quantiles_upper = "xx.x (xx.x - xx.x)" ) lbls <- c( median_ci = "95% CI", range = "Range", range_censor = "Range (censored)", range_event = "Range (event)", - median_long = "Median (95% CI)", + median_ci_3d = "Median (95% CI)", quantiles_lower = "25%-ile (95% CI)", quantiles_upper = "75%-ile (95% CI)" ) diff --git a/R/survival_timepoint.R b/R/survival_timepoint.R index 95190fcbd8..f266837104 100644 --- a/R/survival_timepoint.R +++ b/R/survival_timepoint.R @@ -39,7 +39,7 @@ NULL #' * `event_free_rate`: Event-free rate (%). #' * `rate_se`: Standard error of event free rate. #' * `rate_ci`: Confidence interval for event free rate. -#' * `event_free_rate_long`: Event-free rate (%) with Confidence interval. +#' * `event_free_rate_3d`: Event-free rate (%) with Confidence interval. #' #' @keywords internal s_surv_timepoint <- function(df, @@ -74,14 +74,14 @@ s_surv_timepoint <- function(df, rate_se <- df_srv_fit$std.err rate_ci <- c(df_srv_fit$lower, df_srv_fit$upper) } - event_free_rate_long <- c(event_free_rate, rate_ci) + event_free_rate_3d <- c(event_free_rate, rate_ci) list( pt_at_risk = formatters::with_label(pt_at_risk, "Patients remaining at risk"), event_free_rate = formatters::with_label(event_free_rate * 100, "Event Free Rate (%)"), rate_se = formatters::with_label(rate_se * 100, "Standard Error of Event Free Rate"), rate_ci = formatters::with_label(rate_ci * 100, f_conf_level(conf_level)), - event_free_rate_long = formatters::with_label( - event_free_rate_long * 100, paste0("Event Free Rate (", f_conf_level(conf_level), ")") + event_free_rate_3d = formatters::with_label( + event_free_rate_3d * 100, paste0("Event Free Rate (", f_conf_level(conf_level), ")") ) ) } @@ -115,7 +115,7 @@ a_surv_timepoint <- make_afun( #' * `s_surv_timepoint_diff()` returns the statistics: #' * `rate_diff`: Event-free rate difference between two groups. #' * `rate_diff_ci`: Confidence interval for the difference. -#' * `rate_diff_long`: Event-free rate difference and confidence interval between two groups. +#' * `rate_diff_ci_3d`: Event-free rate difference and confidence interval between two groups. #' * `ztest_pval`: p-value to test the difference is 0. #' #' @keywords internal @@ -131,7 +131,7 @@ s_surv_timepoint_diff <- function(df, list( rate_diff = formatters::with_label("", "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label("", f_conf_level(control$conf_level)), - rate_diff_long = formatters::with_label( + rate_diff_ci_3d = formatters::with_label( "", paste0("Difference in Event Free Rate", f_conf_level(control$conf_level)) ), ztest_pval = formatters::with_label("", "p-value (Z-test)") @@ -151,7 +151,7 @@ s_surv_timepoint_diff <- function(df, qs <- c(-1, 1) * stats::qnorm(1 - (1 - control$conf_level) / 2) rate_diff_ci <- rate_diff + qs * se_diff - rate_diff_long <- c(rate_diff, rate_diff_ci) + rate_diff_ci_3d <- c(rate_diff, rate_diff_ci) ztest_pval <- if (is.na(rate_diff)) { NA } else { @@ -160,8 +160,8 @@ s_surv_timepoint_diff <- function(df, list( rate_diff = formatters::with_label(rate_diff, "Difference in Event Free Rate"), rate_diff_ci = formatters::with_label(rate_diff_ci, f_conf_level(control$conf_level)), - rate_diff_long = formatters::with_label( - rate_diff_long, paste0("Difference in Event Free Rate", f_conf_level(control$conf_level)) + rate_diff_ci_3d = formatters::with_label( + rate_diff_ci_3d, paste0("Difference in Event Free Rate", f_conf_level(control$conf_level)) ), ztest_pval = formatters::with_label(ztest_pval, "p-value (Z-test)") ) @@ -179,7 +179,7 @@ a_surv_timepoint_diff <- make_afun( .formats = c( rate_diff = "xx.xx", rate_diff_ci = "(xx.xx, xx.xx)", - rate_diff_long = format_xx("xx.xx (xx.xx, xx.xx)"), + rate_diff_ci_3d = format_xx("xx.xx (xx.xx, xx.xx)"), ztest_pval = "x.xxxx | (<0.0001)" ) ) @@ -273,8 +273,8 @@ surv_timepoint <- function(lyt, extra_args <- list(time_point = time_point, is_event = is_event, control = control, ...) f <- list( - surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "event_free_rate_long"), - surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval", "rate_diff_long") + surv = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "event_free_rate_3d"), + surv_diff = c("rate_diff", "rate_diff_ci", "ztest_pval", "rate_diff_ci_3d") ) .stats <- h_split_param(.stats, .stats, f = f) .formats <- h_split_param(.formats, names(.formats), f = f) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 0411e32251..b5b64ba378 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -387,8 +387,8 @@ tern_default_stats <- list( "n", "sum", "mean", "sd", "se", "mean_sd", "mean_se", "mean_ci", "mean_sei", "mean_sdi", "mean_pval", "median", "mad", "median_ci", "quantiles", "iqr", "range", "min", "max", "median_range", "cv", "geom_mean", "geom_mean_ci", "geom_cv", - "median_long", - "mean_long", "geom_mean_long" + "median_ci_3d", + "mean_ci_3d", "geom_mean_ci_3d" ), count_cumulative = c("count_fraction", "count_fraction_fixed_dp"), count_missed_doses = c("n", "count_fraction", "count_fraction_fixed_dp"), @@ -409,12 +409,12 @@ tern_default_stats <- list( summarize_num_patients = c("unique", "nonunique", "unique_count"), summarize_patients_events_in_cols = c("unique", "all"), surv_time = c( - "median", "median_ci", "median_long", "quantiles", + "median", "median_ci", "median_ci_3d", "quantiles", "quantiles_lower", "quantiles_upper", "range_censor", "range_event", "range" ), surv_timepoint = c( "pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval", - "event_free_rate_long" + "event_free_rate_3d" ), tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), @@ -450,11 +450,11 @@ tern_default_formats <- c( mean_sei = "(xx.xx, xx.xx)", mean_sdi = "(xx.xx, xx.xx)", mean_pval = "x.xxxx | (<0.0001)", - mean_long = "xx.xx (xx.xx - xx.xx)", + mean_ci_3d = "xx.xx (xx.xx - xx.xx)", median = "xx.x", mad = "xx.x", median_ci = "(xx.xx, xx.xx)", - median_long = "xx.xx (xx.xx - xx.xx)", + median_ci_3d = "xx.xx (xx.xx - xx.xx)", quantiles = "xx.x - xx.x", quantiles_lower = "xx.xx (xx.xx - xx.xx)", quantiles_upper = "xx.xx (xx.xx - xx.xx)", @@ -466,7 +466,7 @@ tern_default_formats <- c( cv = "xx.x", geom_mean = "xx.x", geom_mean_ci = "(xx.xx, xx.xx)", - geom_mean_long = "xx.xx (xx.xx - xx.xx)", + geom_mean_ci_3d = "xx.xx (xx.xx - xx.xx)", geom_cv = "xx.x", pval = "x.xxxx | (<0.0001)", pval_counts = "x.xxxx | (<0.0001)", @@ -504,11 +504,11 @@ tern_default_labels <- c( mean_sei = "Mean -/+ 1xSE", mean_sdi = "Mean -/+ 1xSD", mean_pval = "Mean p-value (H0: mean = 0)", - mean_long = "Mean (95% CI)", + mean_ci_3d = "Mean (95% CI)", median = "Median", mad = "Median Absolute Deviation", median_ci = "Median 95% CI", - median_long = "Median (95% CI)", + median_ci_3d = "Median (95% CI)", quantiles = "25% and 75%-ile", quantiles_lower = "25%-ile (95% CI)", quantiles_upper = "75%-ile (95% CI)", @@ -520,7 +520,7 @@ tern_default_labels <- c( cv = "CV (%)", geom_mean = "Geometric Mean", geom_mean_ci = "Geometric Mean 95% CI", - geom_mean_long = "Geometric Mean (95% CI)", + geom_mean_ci_3d = "Geometric Mean (95% CI)", geom_cv = "CV % Geometric Mean", pval = "p-value (t-test)", # Default for numeric pval_counts = "p-value (chi-squared test)", # Default for counts diff --git a/tests/testthat/_snaps/analyze_variables.md b/tests/testthat/_snaps/analyze_variables.md index dc064755f7..8c10718bdf 100644 --- a/tests/testthat/_snaps/analyze_variables.md +++ b/tests/testthat/_snaps/analyze_variables.md @@ -49,7 +49,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $mean_long + $mean_ci_3d mean mean_ci_lwr mean_ci_upr NA NA NA attr(,"label") @@ -77,7 +77,7 @@ attr(,"label") [1] "Median 95% CI" - $median_long + $median_ci_3d median median_ci_lwr median_ci_upr NA NA NA attr(,"label") @@ -129,7 +129,7 @@ geom_cv NA - $geom_mean_long + $geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr NaN NA NA attr(,"label") @@ -187,7 +187,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $mean_long + $mean_ci_3d mean mean_ci_lwr mean_ci_upr 1 NA NA attr(,"label") @@ -215,7 +215,7 @@ attr(,"label") [1] "Median 95% CI" - $median_long + $median_ci_3d median median_ci_lwr median_ci_upr 1 NA NA attr(,"label") @@ -267,7 +267,7 @@ geom_cv NA - $geom_mean_long + $geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr 1 NA NA attr(,"label") @@ -325,7 +325,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $mean_long + $mean_ci_3d mean mean_ci_lwr mean_ci_upr NA NA NA attr(,"label") @@ -353,7 +353,7 @@ attr(,"label") [1] "Median 95% CI" - $median_long + $median_ci_3d median median_ci_lwr median_ci_upr NA NA NA attr(,"label") @@ -405,7 +405,7 @@ geom_cv NA - $geom_mean_long + $geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr NA NA NA attr(,"label") @@ -463,7 +463,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $mean_long + $mean_ci_3d mean mean_ci_lwr mean_ci_upr 1.500000 -4.853102 7.853102 attr(,"label") @@ -491,7 +491,7 @@ attr(,"label") [1] "Median 95% CI" - $median_long + $median_ci_3d median median_ci_lwr median_ci_upr 1.5 NA NA attr(,"label") @@ -543,7 +543,7 @@ geom_cv 52.10922 - $geom_mean_long + $geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr 1.41421356 0.01729978 115.60839614 attr(,"label") @@ -601,7 +601,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $mean_long + $mean_ci_3d mean mean_ci_lwr mean_ci_upr 6.000000 3.318768 8.681232 attr(,"label") @@ -629,7 +629,7 @@ attr(,"label") [1] "Median 95% CI" - $median_long + $median_ci_3d median median_ci_lwr median_ci_upr 6.5 1.0 10.0 attr(,"label") @@ -681,7 +681,7 @@ geom_cv 96.61307 - $geom_mean_long + $geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr 4.842534 2.456211 9.547283 attr(,"label") diff --git a/tests/testthat/_snaps/compare_variables.md b/tests/testthat/_snaps/compare_variables.md index 0cacb94c3c..6c98b121bb 100644 --- a/tests/testthat/_snaps/compare_variables.md +++ b/tests/testthat/_snaps/compare_variables.md @@ -3,13 +3,13 @@ Code res Output - [1] "n" "sum" "mean" "sd" - [5] "se" "mean_sd" "mean_se" "mean_ci" - [9] "mean_sei" "mean_sdi" "mean_long" "mean_pval" - [13] "median" "mad" "median_ci" "median_long" - [17] "quantiles" "iqr" "range" "min" - [21] "max" "median_range" "cv" "geom_mean" - [25] "geom_mean_ci" "geom_cv" "geom_mean_long" "pval" + [1] "n" "sum" "mean" "sd" + [5] "se" "mean_sd" "mean_se" "mean_ci" + [9] "mean_sei" "mean_sdi" "mean_ci_3d" "mean_pval" + [13] "median" "mad" "median_ci" "median_ci_3d" + [17] "quantiles" "iqr" "range" "min" + [21] "max" "median_range" "cv" "geom_mean" + [25] "geom_mean_ci" "geom_cv" "geom_mean_ci_3d" "pval" # s_compare for numeric does not give p-value when not at least 2 values in each group diff --git a/tests/testthat/_snaps/summarize_change.md b/tests/testthat/_snaps/summarize_change.md index f46df79af1..6b127938a7 100644 --- a/tests/testthat/_snaps/summarize_change.md +++ b/tests/testthat/_snaps/summarize_change.md @@ -49,7 +49,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $mean_long + $mean_ci_3d mean mean_ci_lwr mean_ci_upr NA NA NA attr(,"label") @@ -77,7 +77,7 @@ attr(,"label") [1] "Median 95% CI" - $median_long + $median_ci_3d median median_ci_lwr median_ci_upr NA NA NA attr(,"label") @@ -129,7 +129,7 @@ geom_cv NA - $geom_mean_long + $geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr NaN NA NA attr(,"label") @@ -187,7 +187,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $mean_long + $mean_ci_3d mean mean_ci_lwr mean_ci_upr 3.000000 -4.452413 10.452413 attr(,"label") @@ -215,7 +215,7 @@ attr(,"label") [1] "Median 95% CI" - $median_long + $median_ci_3d median median_ci_lwr median_ci_upr 3 NA NA attr(,"label") @@ -267,7 +267,7 @@ geom_cv NA - $geom_mean_long + $geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr NA NA NA attr(,"label") @@ -326,7 +326,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $`FALSE`$mean_long + $`FALSE`$mean_ci_3d mean mean_ci_lwr mean_ci_upr 1.500000 -4.853102 7.853102 attr(,"label") @@ -354,7 +354,7 @@ attr(,"label") [1] "Median 95% CI" - $`FALSE`$median_long + $`FALSE`$median_ci_3d median median_ci_lwr median_ci_upr 1.5 NA NA attr(,"label") @@ -406,7 +406,7 @@ geom_cv 52.10922 - $`FALSE`$geom_mean_long + $`FALSE`$geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr 1.41421356 0.01729978 115.60839614 attr(,"label") @@ -460,7 +460,7 @@ attr(,"label") [1] "Mean -/+ 1xSD" - $`TRUE`$mean_long + $`TRUE`$mean_ci_3d mean mean_ci_lwr mean_ci_upr 2.50000 -16.55931 21.55931 attr(,"label") @@ -488,7 +488,7 @@ attr(,"label") [1] "Median 95% CI" - $`TRUE`$median_long + $`TRUE`$median_ci_3d median median_ci_lwr median_ci_upr 2.5 NA NA attr(,"label") @@ -540,7 +540,7 @@ geom_cv 127.0458 - $`TRUE`$geom_mean_long + $`TRUE`$geom_mean_ci_3d geom_mean mean_ci_lwr mean_ci_upr 2.000000e+00 2.992824e-04 1.336530e+04 attr(,"label") diff --git a/tests/testthat/_snaps/survival_coxph_pairwise.md b/tests/testthat/_snaps/survival_coxph_pairwise.md index 3c81dbda37..a309f01b0a 100644 --- a/tests/testthat/_snaps/survival_coxph_pairwise.md +++ b/tests/testthat/_snaps/survival_coxph_pairwise.md @@ -18,7 +18,7 @@ attr(,"label") [1] "95% CI" - $hr_long + $hr_ci_3d [1] 0.7108557 0.4779138 1.0573368 attr(,"label") [1] "Hazard Ratio (95% CI)" @@ -54,7 +54,7 @@ attr(,"label") [1] "90% CI" - $hr_long + $hr_ci_3d [1] 0.7108557 0.5094153 0.9919525 attr(,"label") [1] "Hazard Ratio (90% CI)" @@ -90,7 +90,7 @@ attr(,"label") [1] "95% CI" - $hr_long + $hr_ci_3d [1] 0.6251817 0.4014842 0.9735181 attr(,"label") [1] "Hazard Ratio (95% CI)" @@ -126,7 +126,7 @@ attr(,"label") [1] "90% CI" - $hr_long + $hr_ci_3d [1] 0.6251817 0.4311132 0.9066115 attr(,"label") [1] "Hazard Ratio (90% CI)" diff --git a/tests/testthat/_snaps/survival_time.md b/tests/testthat/_snaps/survival_time.md index dad2784e94..10d0453dce 100644 --- a/tests/testthat/_snaps/survival_time.md +++ b/tests/testthat/_snaps/survival_time.md @@ -33,7 +33,7 @@ attr(,"label") [1] "Range" - $median_long + $median_ci_3d [1] 23.91143 18.25878 32.85945 attr(,"label") [1] "Median (95% CI)" @@ -84,7 +84,7 @@ attr(,"label") [1] "Range" - $median_long + $median_ci_3d [1] 23.91143 13.59124 37.97055 attr(,"label") [1] "Median (99% CI)" diff --git a/tests/testthat/_snaps/survival_timepoint.md b/tests/testthat/_snaps/survival_timepoint.md index 1ca511c166..18e7f1f433 100644 --- a/tests/testthat/_snaps/survival_timepoint.md +++ b/tests/testthat/_snaps/survival_timepoint.md @@ -23,7 +23,7 @@ attr(,"label") [1] "95% CI" - $event_free_rate_long + $event_free_rate_3d [1] 82.19178 73.41549 90.96807 attr(,"label") [1] "Event Free Rate (95% CI)" @@ -54,7 +54,7 @@ attr(,"label") [1] "99% CI" - $event_free_rate_long + $event_free_rate_3d [1] 75.49797 62.15793 91.70097 attr(,"label") [1] "Event Free Rate (99% CI)" @@ -85,7 +85,7 @@ attr(,"label") [1] "95% CI" - $event_free_rate_long + $event_free_rate_3d [1] NA NA NA attr(,"label") [1] "Event Free Rate (95% CI)" @@ -130,7 +130,7 @@ attr(,"label") [1] "95% CI" - $rate_diff_long + $rate_diff_ci_3d [1] 4.269100 -7.767371 16.305570 attr(,"label") [1] "Difference in Event Free Rate95% CI" @@ -156,7 +156,7 @@ attr(,"label") [1] "90% CI" - $rate_diff_long + $rate_diff_ci_3d [1] 9.640872 -1.404177 20.685921 attr(,"label") [1] "Difference in Event Free Rate90% CI" diff --git a/tests/testthat/_snaps/utils_default_stats_formats_labels.md b/tests/testthat/_snaps/utils_default_stats_formats_labels.md index ea57d3c8a2..87115adb62 100644 --- a/tests/testthat/_snaps/utils_default_stats_formats_labels.md +++ b/tests/testthat/_snaps/utils_default_stats_formats_labels.md @@ -33,7 +33,7 @@ [13] "mad" "median_ci" "quantiles" "iqr" [17] "range" "min" "max" "median_range" [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" - [25] "median_long" "mean_long" "geom_mean_long" + [25] "median_ci_3d" "mean_ci_3d" "geom_mean_ci_3d" # get_labels_from_stats works as expected @@ -100,7 +100,7 @@ "xx.x" "xx.x (xx.x - xx.x)" "xx.x" geom_mean geom_mean_ci geom_cv "xx.x" "(xx.xx, xx.xx)" "xx.x" - median_long mean_long geom_mean_long + median_ci_3d mean_ci_3d geom_mean_ci_3d "xx.xx (xx.xx - xx.xx)" "xx.xx (xx.xx - xx.xx)" "xx.xx (xx.xx - xx.xx)" # summary_labels works as expected @@ -132,9 +132,9 @@ "CV (%)" "Geometric Mean" geom_mean_ci geom_cv "Geometric Mean 95% CI" "CV % Geometric Mean" - median_long mean_long + median_ci_3d mean_ci_3d "Median (95% CI)" "Mean (95% CI)" - geom_mean_long + geom_mean_ci_3d "Geometric Mean (95% CI)" ---