diff --git a/R/cfbt01.R b/R/cfbt01.R index 6a06149bf..1480c9803 100644 --- a/R/cfbt01.R +++ b/R/cfbt01.R @@ -8,9 +8,11 @@ #' @param visitvar (`string`) typically one of `"AVISIT"` (Default) or `"ATPTN"` depending on the type of time point #' to be displayed #' @param precision (named `list` of `integer`) where names are values found in the `PARAMCD` column and the the values -#' indicate the number of digits that should be represented for `min`, `max` and `median`. `Mean` and `sd` are -#' represented with one more decimal of precision. -#' @param default_precision (`integer`) the default number of digits. +#' indicate the number of digits in statistics. If `default` is set, and parameter precision not specified, +#' the value for `default` will be used. +#' @param .stats (`character`) statistics names, see `tern::summarize_vars()`. +#' @param skip Named (`list`) of visit values that need to be inhibited. +#' @param ... additional arguments like `.indent_mods`, `.labels`. #' #' @details #' * The `Analysis Value` column, displays the number of patients, the mean, standard deviation, median and range of @@ -34,13 +36,14 @@ cfbt01_main <- function(adam_db, row_split_var = NULL, summaryvars = c("AVAL", "CHG"), visitvar = "AVISIT", - precision = list(), - default_precision = 2, - page_var = NULL, + precision = list(default = 2L), + page_var = "PARAMCD", + .stats = c("n", "mean_sd", "median", "range"), + skip = list(CHG = "BASELINE"), ...) { assert_all_tablenames(adam_db, c("adsl", dataset)) checkmate::assert_string(arm_var) - checkmate::assert_character(summaryvars, len = 2) + checkmate::assert_character(summaryvars, max.len = 2L, min.len = 1L) checkmate::assert_character(row_split_var, null.ok = TRUE) checkmate::assert_disjunct(row_split_var, c("PARAMCD", "PARAM", visitvar)) checkmate::assert_string(visitvar) @@ -60,8 +63,12 @@ cfbt01_main <- function(adam_db, assert_valid_var_pair(adam_db$adsl, adam_db[[dataset]], arm_var) checkmate::assert_list(precision, types = "integerish", names = "unique") vapply(precision, checkmate::assert_int, FUN.VALUE = numeric(1), lower = 0) - checkmate::assert_integerish(default_precision, lower = 0) - + all_stats <- 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", + "cv", "min", "max", "median_range", "geom_mean", "geom_cv" + ) + checkmate::assert_subset(.stats, all_stats) lbl_avisit <- var_labels_for(adam_db[[dataset]], visitvar) lbl_param <- var_labels_for(adam_db[[dataset]], "PARAM") @@ -78,10 +85,11 @@ cfbt01_main <- function(adam_db, lbl_avisit = lbl_avisit, lbl_param = lbl_param, precision = precision, - default_precision = default_precision, - page_var = page_var + .stats = .stats, + page_var = page_var, + skip = skip, + ... ) - tbl <- build_table( lyt, df = adam_db[[dataset]], @@ -115,9 +123,11 @@ cfbt01_lyt <- function(arm_var, lbl_avisit, lbl_param, precision, - default_precision, - page_var) { - page_by <- get_page_by(page_var, c(row_split_var, "PARAMCD", visitvar)) + page_var, + .stats, + skip, + ...) { + page_by <- get_page_by(page_var, c(row_split_var, "PARAMCD")) label_pos <- dplyr::if_else(page_by, "hidden", "topleft") basic_table(show_colcounts = TRUE) %>% split_cols_by(arm_var) %>% @@ -146,13 +156,14 @@ cfbt01_lyt <- function(arm_var, nested = TRUE ) %>% analyze_colvars( - afun = afun_skip_baseline, + afun = afun_skip, extra_args = list( visitvar = visitvar, paramcdvar = "PARAMCD", - skip = c("BASELINE" = summaryvars[2]), + skip = skip, precision = precision, - default_precision = default_precision + .stats = .stats, + ... ) ) } diff --git a/R/rtables_utils.R b/R/rtables_utils.R index 6e0cb59f3..4ad657cb2 100644 --- a/R/rtables_utils.R +++ b/R/rtables_utils.R @@ -375,50 +375,64 @@ ifneeded_add_overall_col <- function(lyt, lbl_overall) { #' @param paramcdvar (`string`) name of parameter code. #' @param visitvar (`string`) name of the visit variable. #' @param skip Named (`character`) indicating the pairs to skip in analyze. +#' @param .stats (`character`) See `tern::summarize_variables`. +#' @param .label (`character`) See `tern::summarize_variables`. +#' @param .indent_mods (`integer`) See `tern::summarize_variables`. +#' @param .N_col (`int`) See `tern::summarize_variables`. +#' @param .N_row (`int`) See `tern::summarize_variables`. +#' @param ... additional arguments for `tern::create_afun_summary`. #' @inheritParams cfbt01_main #' @keywords internal -afun_skip_baseline <- function(x, .var, .spl_context, paramcdvar, visitvar, skip, precision, default_precision, ...) { +afun_skip <- function( + x, .var, .spl_context, paramcdvar, visitvar, skip, + precision, .stats, .labels = NULL, .indent_mods = NULL, .N_col, .N_row, ...) { # nolint param_val <- .spl_context$value[which(.spl_context$split == paramcdvar)] - pcs <- precision[[param_val]] %||% default_precision - - # Create context dependent function. - n_fun <- sum(!is.na(x), na.rm = TRUE) - if (n_fun == 0) { - mean_sd_fun <- c(NA, NA) - median_fun <- NA - min_max_fun <- c(NA, NA) + # Identify context + split_level <- .spl_context$value[which(.spl_context$split == visitvar)] + pcs <- if (.var %in% names(skip) && split_level %in% skip[[.var]]) { + NA } else { - mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE)) - median_fun <- median(x, na.rm = TRUE) - min_max_fun <- c(min(x), max(x)) + precision[[param_val]] %||% precision[["default"]] %||% 2 } - # Identify context- - is_chg <- .var == skip - - is_baseline <- .spl_context$value[which(.spl_context$split == visitvar)] == names(skip) - - if (is_baseline && is_chg) { - n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL + fmts <- lapply(.stats, summary_formats, pcs = pcs, FALSE) + names(fmts) <- .stats + fmts_na <- lapply(.stats, summary_formats, pcs = pcs, ne = TRUE) + ret <- tern::create_afun_summary( + .stats, fmts, .labels, .indent_mods + )(x = x, .var = .var, .spl_context = .spl_context, .N_col = .N_col, .N_row = .N_row, ...) + for (i in seq_len(length(ret))) { + attr(ret[[i]], "format_na_str") <- fmts_na[[i]]() } + ret +} - in_rows( - "n" = n_fun, - "Mean (SD)" = mean_sd_fun, - "Median" = median_fun, - "Min - Max" = min_max_fun, - .formats = list( - "n" = "xx", - "Mean (SD)" = h_format_dec(format = "%f (%f)", digits = pcs + 1), - "Median" = h_format_dec(format = "%f", digits = pcs + 1), - "Min - Max" = h_format_dec(format = "%f - %f", digits = pcs) - ), - .format_na_strs = list( - "n" = "NE", - "Mean (SD)" = "NE (NE)", - "Median" = "NE", - "Min - Max" = "NE - NE" - ) +summary_formats <- function(x, pcs, ne = FALSE) { + checkmate::assert_int(pcs, lower = 0, na.ok = TRUE) + switch(x, + n = h_format_dec(format = "%s", digits = pcs - pcs, ne = ne), + min = , + max = , + sum = h_format_dec(format = "%s", digits = pcs, ne = ne), + mean = , + sd = , + median = , + mad = , + iqr = , + cv = , + geom_mean = , + geom_cv = , + se = h_format_dec(format = "%s", digits = pcs + 1, ne = ne), + mean_sd = , + mean_se = h_format_dec(format = "%s (%s)", digits = rep(pcs + 1, 2), ne = ne), + mean_ci = , + mean_sei = , + median_ci = , + mean_sdi = h_format_dec(format = "(%s, %s)", digits = rep(pcs + 1, 2), ne = ne), + mean_pval = h_format_dec(format = "%s", digits = 2, ne = ne), + quantiles = h_format_dec(format = "(%s - %s)", digits = rep(pcs + 1, 2), ne = ne), + range = h_format_dec(format = "%s - %s", digits = rep(pcs, 2), ne = ne), + median_range = h_format_dec(format = "%s (%s - %s)", digits = c(pcs, pcs + 1, pcs + 1), ne = ne) ) } diff --git a/R/utils.R b/R/utils.R index 05be3cdd5..00f18cbdf 100755 --- a/R/utils.R +++ b/R/utils.R @@ -64,30 +64,33 @@ std_postprocess <- function(tlg, ind = 2L, ...) { #' #' @param digits (`integer`) number of digits. #' @param format (`string`) describing how the numbers should be formatted following the `sprintf` syntax. +#' @param ne (`flag`) indicator whether to use "NE" to replace the actual value. #' -#' @return `function` formatting numbers with the defined format or `NULL` if the format is not defined. +#' @return `function` formatting numbers with the defined format. #' #' @export #' #' @examples -#' fun <- h_format_dec(1, "%f - %f") +#' fun <- h_format_dec(c(1, 1), "%s - %s") #' fun(c(123, 567.89)) #' -h_format_dec <- function(digits = NA, format = NA) { - checkmate::assert_int(digits, lower = 0, na.ok = TRUE) - checkmate::assert_string(format, na.ok = TRUE) - - if (is.na(format)) { - NULL - } else { +h_format_dec <- function(digits, format, ne = FALSE) { + checkmate::assert_integerish(digits, lower = 0) + checkmate::assert_string(format) + if (any(is.na(digits))) { function(x, ...) { - checkmate::assert_numeric(x) - - digit_string <- ifelse(is.na(digits), "", paste0(".", digits)) - new_format <- gsub("%([a-z])", paste0("%", digit_string, "\\1"), format) - - formatters::sprintf_format(new_format)(x) + "" + } + } else { + if (ne) { + ret <- function(x, ...) { + do.call(sprintf, c(list(fmt = format), rep("NE", length(digits)))) + } + return(ret) } + digit_string <- paste0("%", ifelse(is.na(digits), "", paste0(".", digits)), "f") + new_format <- do.call(sprintf, c(list(fmt = format), digit_string)) + formatters::sprintf_format(new_format) } } diff --git a/man/afun_skip_baseline.Rd b/man/afun_skip.Rd similarity index 50% rename from man/afun_skip_baseline.Rd rename to man/afun_skip.Rd index 5e955189b..bf33af0eb 100644 --- a/man/afun_skip_baseline.Rd +++ b/man/afun_skip.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rtables_utils.R -\name{afun_skip_baseline} -\alias{afun_skip_baseline} +\name{afun_skip} +\alias{afun_skip} \title{Analyze skip baseline} \usage{ -afun_skip_baseline( +afun_skip( x, .var, .spl_context, @@ -12,7 +12,11 @@ afun_skip_baseline( visitvar, skip, precision, - default_precision, + .stats, + .labels = NULL, + .indent_mods = NULL, + .N_col, + .N_row, ... ) } @@ -30,12 +34,20 @@ afun_skip_baseline( \item{skip}{Named (\code{character}) indicating the pairs to skip in analyze.} \item{precision}{(named \code{list} of \code{integer}) where names are values found in the \code{PARAMCD} column and the the values -indicate the number of digits that should be represented for \code{min}, \code{max} and \code{median}. \code{Mean} and \code{sd} are -represented with one more decimal of precision.} +indicate the number of digits in statistics. If \code{default} is set, and parameter precision not specified, +the value for \code{default} will be used.} -\item{default_precision}{(\code{integer}) the default number of digits.} +\item{.stats}{(\code{character}) See \code{tern::summarize_variables}.} -\item{...}{not used.} +\item{.indent_mods}{(\code{integer}) See \code{tern::summarize_variables}.} + +\item{.N_col}{(\code{int}) See \code{tern::summarize_variables}.} + +\item{.N_row}{(\code{int}) See \code{tern::summarize_variables}.} + +\item{...}{additional arguments for \code{tern::create_afun_summary}.} + +\item{.label}{(\code{character}) See \code{tern::summarize_variables}.} } \description{ Analyze skip baseline diff --git a/man/cfbt01.Rd b/man/cfbt01.Rd index 7e356c4c9..06edcb4b8 100644 --- a/man/cfbt01.Rd +++ b/man/cfbt01.Rd @@ -18,9 +18,10 @@ cfbt01_main( row_split_var = NULL, summaryvars = c("AVAL", "CHG"), visitvar = "AVISIT", - precision = list(), - default_precision = 2, - page_var = NULL, + precision = list(default = 2L), + page_var = "PARAMCD", + .stats = c("n", "mean_sd", "median", "range"), + skip = list(CHG = "BASELINE"), ... ) @@ -46,14 +47,16 @@ table of \code{adam_db} is used as label.} to be displayed} \item{precision}{(named \code{list} of \code{integer}) where names are values found in the \code{PARAMCD} column and the the values -indicate the number of digits that should be represented for \code{min}, \code{max} and \code{median}. \code{Mean} and \code{sd} are -represented with one more decimal of precision.} - -\item{default_precision}{(\code{integer}) the default number of digits.} +indicate the number of digits in statistics. If \code{default} is set, and parameter precision not specified, +the value for \code{default} will be used.} \item{page_var}{(\code{string}) variable name prior to which the row split is by page.} -\item{...}{not used.} +\item{.stats}{(\code{character}) statistics names, see \code{tern::summarize_vars()}.} + +\item{skip}{Named (\code{list}) of visit values that need to be inhibited.} + +\item{...}{additional arguments like \code{.indent_mods}, \code{.labels}.} \item{tlg}{(\code{TableTree}, \code{Listing} or \code{ggplot}) object typically produced by a \code{main} function.} diff --git a/man/cfbt01_lyt.Rd b/man/cfbt01_lyt.Rd index c9f65c57c..ce88a599b 100644 --- a/man/cfbt01_lyt.Rd +++ b/man/cfbt01_lyt.Rd @@ -14,8 +14,10 @@ cfbt01_lyt( lbl_avisit, lbl_param, precision, - default_precision, - page_var + page_var, + .stats, + skip, + ... ) } \arguments{ @@ -37,12 +39,16 @@ to be displayed.} \item{lbl_param}{(\code{string}) label of the \code{PARAM} variable.} \item{precision}{(named \code{list} of \code{integer}) where names are values found in the \code{PARAMCD} column and the the values -indicate the number of digits that should be represented for \code{min}, \code{max} and \code{median}. \code{Mean} and \code{sd} are -represented with one more decimal of precision.} - -\item{default_precision}{(\code{integer}) the default number of digits.} +indicate the number of digits in statistics. If \code{default} is set, and parameter precision not specified, +the value for \code{default} will be used.} \item{page_var}{(\code{string}) variable name prior to which the row split is by page.} + +\item{.stats}{(\code{character}) statistics names, see \code{tern::summarize_vars()}.} + +\item{skip}{Named (\code{list}) of visit values that need to be inhibited.} + +\item{...}{not used.} } \description{ \code{cfbt01} Layout diff --git a/man/egt01.Rd b/man/egt01.Rd index 6ffc398a5..f468c38a9 100644 --- a/man/egt01.Rd +++ b/man/egt01.Rd @@ -20,9 +20,10 @@ egt01_main( row_split_var = NULL, summaryvars = c("AVAL", "CHG"), visitvar = "AVISIT", - precision = list(), - default_precision = 2, - page_var = NULL, + precision = list(default = 2L), + page_var = "PARAMCD", + .stats = c("n", "mean_sd", "median", "range"), + skip = list(CHG = "BASELINE"), ... ) @@ -46,14 +47,16 @@ table of \code{adam_db} is used as label.} to be displayed} \item{precision}{(named \code{list} of \code{integer}) where names are values found in the \code{PARAMCD} column and the the values -indicate the number of digits that should be represented for \code{min}, \code{max} and \code{median}. \code{Mean} and \code{sd} are -represented with one more decimal of precision.} - -\item{default_precision}{(\code{integer}) the default number of digits.} +indicate the number of digits in statistics. If \code{default} is set, and parameter precision not specified, +the value for \code{default} will be used.} \item{page_var}{(\code{string}) variable name prior to which the row split is by page.} -\item{...}{not used.} +\item{.stats}{(\code{character}) statistics names, see \code{tern::summarize_vars()}.} + +\item{skip}{Named (\code{list}) of visit values that need to be inhibited.} + +\item{...}{additional arguments like \code{.indent_mods}, \code{.labels}.} } \description{ The \code{EGT01} table provides an diff --git a/man/h_format_dec.Rd b/man/h_format_dec.Rd index 00679eb08..39e6808b0 100755 --- a/man/h_format_dec.Rd +++ b/man/h_format_dec.Rd @@ -4,21 +4,23 @@ \alias{h_format_dec} \title{Decimal Formatting} \usage{ -h_format_dec(digits = NA, format = NA) +h_format_dec(digits, format, ne = FALSE) } \arguments{ \item{digits}{(\code{integer}) number of digits.} \item{format}{(\code{string}) describing how the numbers should be formatted following the \code{sprintf} syntax.} + +\item{ne}{(\code{flag}) indicator whether to use "NE" to replace the actual value.} } \value{ -\code{function} formatting numbers with the defined format or \code{NULL} if the format is not defined. +\code{function} formatting numbers with the defined format. } \description{ Decimal Formatting } \examples{ -fun <- h_format_dec(1, "\%f - \%f") +fun <- h_format_dec(c(1, 1), "\%s - \%s") fun(c(123, 567.89)) } diff --git a/man/lbt01.Rd b/man/lbt01.Rd index 21fbae5ac..349749c44 100644 --- a/man/lbt01.Rd +++ b/man/lbt01.Rd @@ -20,9 +20,10 @@ lbt01_main( row_split_var = NULL, summaryvars = c("AVAL", "CHG"), visitvar = "AVISIT", - precision = list(), - default_precision = 2, - page_var = NULL, + precision = list(default = 2L), + page_var = "PARAMCD", + .stats = c("n", "mean_sd", "median", "range"), + skip = list(CHG = "BASELINE"), ... ) @@ -46,14 +47,16 @@ table of \code{adam_db} is used as label.} to be displayed} \item{precision}{(named \code{list} of \code{integer}) where names are values found in the \code{PARAMCD} column and the the values -indicate the number of digits that should be represented for \code{min}, \code{max} and \code{median}. \code{Mean} and \code{sd} are -represented with one more decimal of precision.} - -\item{default_precision}{(\code{integer}) the default number of digits.} +indicate the number of digits in statistics. If \code{default} is set, and parameter precision not specified, +the value for \code{default} will be used.} \item{page_var}{(\code{string}) variable name prior to which the row split is by page.} -\item{...}{not used.} +\item{.stats}{(\code{character}) statistics names, see \code{tern::summarize_vars()}.} + +\item{skip}{Named (\code{list}) of visit values that need to be inhibited.} + +\item{...}{additional arguments like \code{.indent_mods}, \code{.labels}.} } \description{ The \code{LBT01} table provides an diff --git a/man/vst01.Rd b/man/vst01.Rd index cc07fb732..263dc77b7 100644 --- a/man/vst01.Rd +++ b/man/vst01.Rd @@ -20,9 +20,10 @@ vst01_main( row_split_var = NULL, summaryvars = c("AVAL", "CHG"), visitvar = "AVISIT", - precision = list(), - default_precision = 2, - page_var = NULL, + precision = list(default = 2L), + page_var = "PARAMCD", + .stats = c("n", "mean_sd", "median", "range"), + skip = list(CHG = "BASELINE"), ... ) @@ -46,14 +47,16 @@ table of \code{adam_db} is used as label.} to be displayed} \item{precision}{(named \code{list} of \code{integer}) where names are values found in the \code{PARAMCD} column and the the values -indicate the number of digits that should be represented for \code{min}, \code{max} and \code{median}. \code{Mean} and \code{sd} are -represented with one more decimal of precision.} - -\item{default_precision}{(\code{integer}) the default number of digits.} +indicate the number of digits in statistics. If \code{default} is set, and parameter precision not specified, +the value for \code{default} will be used.} \item{page_var}{(\code{string}) variable name prior to which the row split is by page.} -\item{...}{not used.} +\item{.stats}{(\code{character}) statistics names, see \code{tern::summarize_vars()}.} + +\item{skip}{Named (\code{list}) of visit values that need to be inhibited.} + +\item{...}{additional arguments like \code{.indent_mods}, \code{.labels}.} } \description{ The \code{VST01} table provides an diff --git a/tests/testthat/_snaps/egt01.md b/tests/testthat/_snaps/egt01.md index 7eb3edfdb..c8c1463f9 100644 --- a/tests/testthat/_snaps/egt01.md +++ b/tests/testthat/_snaps/egt01.md @@ -1,106 +1,242 @@ # egt01 functions with default argument value return expected result with test data Code - res + cat(export_as_txt(res, lpp = 100)) Output - Analysis Visit A: Drug X B: Placebo C: Combination - Change from Change from Change from - Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline - (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) - ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— - Heart Rate - BASELINE - n 134 134 132 - Mean (SD) 71.447 (17.932) 69.829 (20.717) 69.341 (20.948) - Median 72.697 73.352 71.956 - Min - Max 9.09 - 106.91 13.49 - 115.52 11.63 - 115.49 - WEEK 1 DAY 8 - n 134 134 134 134 132 132 - Mean (SD) 70.191 (20.274) -1.257 (25.966) 69.427 (20.799) -0.401 (29.735) 68.654 (18.064) -0.687 (27.807) - Median 70.703 -2.197 70.462 -0.520 68.573 -0.760 - Min - Max 8.53 - 127.50 -50.97 - 89.16 16.85 - 129.14 -68.18 - 88.38 16.87 - 115.60 -68.25 - 67.20 - WEEK 2 DAY 15 - n 134 134 134 134 132 132 - Mean (SD) 70.317 (19.561) -1.130 (26.262) 71.108 (20.556) 1.279 (31.353) 69.193 (18.056) -0.148 (28.606) - Median 70.885 -1.105 72.524 -0.311 69.304 -1.548 - Min - Max 17.14 - 116.32 -85.03 - 67.52 9.22 - 120.54 -73.07 - 81.44 29.62 - 120.50 -67.75 - 66.29 - WEEK 3 DAY 22 - n 134 134 134 134 132 132 - Mean (SD) 68.251 (20.168) -3.196 (28.657) 68.947 (20.558) -0.881 (30.142) 70.884 (20.280) 1.543 (27.285) - Median 68.787 -2.167 67.802 1.195 70.124 0.139 - Min - Max 13.33 - 131.73 -81.20 - 72.57 23.98 - 130.41 -73.03 - 103.31 20.91 - 116.79 -64.51 - 72.52 - WEEK 4 DAY 29 - n 134 134 134 134 132 132 - Mean (SD) 70.063 (18.410) -1.385 (26.595) 71.601 (20.336) 1.772 (30.262) 71.020 (20.591) 1.679 (29.597) - Median 69.330 -4.535 72.211 -0.884 70.523 3.811 - Min - Max 22.30 - 116.51 -58.07 - 77.32 17.53 - 129.06 -64.32 - 85.34 10.35 - 117.30 -65.91 - 105.67 - WEEK 5 DAY 36 - n 134 134 134 134 132 132 - Mean (SD) 66.406 (19.745) -5.041 (27.112) 71.252 (18.923) 1.423 (27.084) 71.257 (18.563) 1.916 (29.591) - Median 65.405 -6.827 70.858 0.637 73.292 1.735 - Min - Max 23.89 - 110.38 -73.26 - 57.24 25.86 - 125.73 -71.15 - 67.37 23.89 - 117.19 -58.23 - 68.86 - QT Duration - BASELINE - n 134 134 132 - Mean (SD) 336.834 (117.958) 351.004 (98.436) 352.598 (105.114) - Median 344.414 351.480 347.956 - Min - Max 86.98 - 665.40 98.90 - 641.92 105.68 - 628.14 - WEEK 1 DAY 8 - n 134 134 134 134 132 132 - Mean (SD) 342.574 (101.093) 5.741 (159.936) 363.946 (102.338) 12.943 (140.729) 359.424 (105.161) 6.826 (147.129) - Median 347.264 -1.779 356.539 13.730 363.838 8.685 - Min - Max 91.63 - 591.42 -346.44 - 452.75 114.92 - 656.45 -317.53 - 416.35 51.91 - 611.88 -473.19 - 358.00 - WEEK 2 DAY 15 - n 134 134 134 134 132 132 - Mean (SD) 353.244 (93.926) 16.410 (162.103) 345.926 (96.783) -5.078 (152.509) 335.689 (98.605) -16.909 (138.448) - Median 351.099 16.722 346.831 -9.681 320.957 -22.267 - Min - Max 138.01 - 587.30 -414.07 - 389.16 146.42 - 556.07 -440.28 - 364.76 104.91 - 562.34 -326.55 - 325.27 - WEEK 3 DAY 22 - n 134 134 134 134 132 132 - Mean (SD) 370.115 (101.568) 33.282 (152.780) 343.412 (102.585) -7.592 (138.803) 346.947 (94.965) -5.652 (144.651) - Median 378.209 39.586 335.119 -15.888 352.154 9.113 - Min - Max 118.14 - 615.18 -391.72 - 520.09 63.37 - 566.51 -311.28 - 293.76 126.09 - 580.81 -412.11 - 410.01 - WEEK 4 DAY 29 - n 134 134 134 134 132 132 - Mean (SD) 345.774 (95.970) 8.941 (145.647) 354.377 (108.286) 3.374 (142.390) 341.358 (106.745) -11.240 (145.648) - Median 340.134 5.576 346.699 -17.129 352.295 -11.868 - Min - Max 110.12 - 616.58 -393.34 - 456.04 80.82 - 687.69 -439.90 - 364.80 4.95 - 570.61 -480.94 - 330.67 - WEEK 5 DAY 36 - n 134 134 134 134 132 132 - Mean (SD) 358.903 (97.693) 22.069 (155.681) 338.648 (99.260) -12.356 (130.457) 349.303 (95.769) -3.296 (135.997) - Median 351.959 5.886 344.167 0.405 350.319 12.680 - Min - Max 88.38 - 661.12 -353.30 - 539.84 31.25 - 563.90 -338.85 - 352.75 119.02 - 581.83 -311.45 - 295.53 - RR Duration - BASELINE - n 134 134 132 - Mean (SD) 1028.419 (286.385) 1027.484 (324.000) 1074.623 (277.328) - Median 1041.860 1047.268 1080.866 - Min - Max 34.33 - 1783.71 5.29 - 1877.19 289.60 - 1617.06 - WEEK 1 DAY 8 - n 134 134 134 134 132 132 - Mean (SD) 990.155 (318.736) -38.264 (446.403) 1061.587 (269.138) 34.103 (401.759) 1039.642 (284.389) -34.981 (406.037) - Median 963.881 -86.501 1061.504 66.914 1014.780 -97.826 - Min - Max 110.82 - 2014.56 -1014.82 - 1389.40 276.83 - 1711.99 -942.16 - 993.82 498.21 - 1937.47 -958.61 - 908.90 - WEEK 2 DAY 15 - n 134 134 134 134 132 132 - Mean (SD) 1013.371 (304.135) -15.047 (425.807) 1109.402 (318.227) 81.918 (453.105) 1045.209 (277.506) -29.414 (380.841) - Median 1040.693 40.485 1117.764 69.275 1034.637 -15.331 - Min - Max 164.19 - 1677.10 -1216.10 - 1053.15 160.73 - 2048.73 -1127.10 - 1148.61 252.84 - 1722.33 -859.27 - 871.54 - WEEK 3 DAY 22 - n 134 134 134 134 132 132 - Mean (SD) 1013.987 (304.990) -14.431 (406.529) 1118.345 (296.527) 90.861 (409.573) 1036.593 (268.521) -38.030 (421.484) - Median 1027.232 -50.543 1134.596 52.029 1030.717 -60.720 - Min - Max 357.04 - 1798.65 -882.94 - 1080.26 97.14 - 1825.43 -887.06 - 1166.15 446.02 - 1713.38 -984.79 - 902.37 - WEEK 4 DAY 29 - n 134 134 134 134 132 132 - Mean (SD) 1033.309 (313.919) 4.890 (483.153) 1079.762 (298.940) 52.278 (429.253) 1027.549 (295.856) -47.074 (378.235) - Median 1050.399 5.601 1051.613 69.554 1023.360 -49.519 - Min - Max 54.33 - 1979.43 -1345.93 - 1195.41 347.94 - 1762.04 -826.43 - 1191.83 341.62 - 2144.86 -1002.03 - 1048.66 - WEEK 5 DAY 36 - n 134 134 134 134 132 132 - Mean (SD) 1072.335 (282.901) 43.916 (379.048) 1058.452 (271.012) 30.968 (436.030) 1029.043 (271.211) -45.580 (405.528) - Median 1067.330 55.872 1068.950 33.615 1065.256 -34.395 - Min - Max 352.97 - 2000.56 -1028.79 - 1418.57 208.83 - 1794.73 -978.97 - 1365.13 436.28 - 1794.07 -962.18 - 1329.88 + + Parameter: Heart Rate + + ——————————————————————————————————————————————————————————————————————————————————————————————————— + Analysis Visit A: Drug X B: Placebo + Change from Change from + Value at Visit Baseline Value at Visit Baseline + (N=134) (N=134) (N=134) (N=134) + ——————————————————————————————————————————————————————————————————————————————————————————————————— + BASELINE + n 134 134 + Mean (SD) 71.447 (17.932) 69.829 (20.717) + Median 72.697 73.352 + Min - Max 9.09 - 106.91 13.49 - 115.52 + WEEK 1 DAY 8 + n 134 134 134 134 + Mean (SD) 70.191 (20.274) -1.257 (25.966) 69.427 (20.799) -0.401 (29.735) + Median 70.703 -2.197 70.462 -0.520 + Min - Max 8.53 - 127.50 -50.97 - 89.16 16.85 - 129.14 -68.18 - 88.38 + WEEK 2 DAY 15 + n 134 134 134 134 + Mean (SD) 70.317 (19.561) -1.130 (26.262) 71.108 (20.556) 1.279 (31.353) + Median 70.885 -1.105 72.524 -0.311 + Min - Max 17.14 - 116.32 -85.03 - 67.52 9.22 - 120.54 -73.07 - 81.44 + WEEK 3 DAY 22 + n 134 134 134 134 + Mean (SD) 68.251 (20.168) -3.196 (28.657) 68.947 (20.558) -0.881 (30.142) + Median 68.787 -2.167 67.802 1.195 + Min - Max 13.33 - 131.73 -81.20 - 72.57 23.98 - 130.41 -73.03 - 103.31 + WEEK 4 DAY 29 + n 134 134 134 134 + Mean (SD) 70.063 (18.410) -1.385 (26.595) 71.601 (20.336) 1.772 (30.262) + Median 69.330 -4.535 72.211 -0.884 + Min - Max 22.30 - 116.51 -58.07 - 77.32 17.53 - 129.06 -64.32 - 85.34 + WEEK 5 DAY 36 + n 134 134 134 134 + Mean (SD) 66.406 (19.745) -5.041 (27.112) 71.252 (18.923) 1.423 (27.084) + Median 65.405 -6.827 70.858 0.637 + Min - Max 23.89 - 110.38 -73.26 - 57.24 25.86 - 125.73 -71.15 - 67.37 + \s\n + Parameter: Heart Rate + + ————————————————————————————————————————————————————————— + Analysis Visit C: Combination + Change from + Value at Visit Baseline + (N=132) (N=132) + ————————————————————————————————————————————————————————— + BASELINE + n 132 + Mean (SD) 69.341 (20.948) + Median 71.956 + Min - Max 11.63 - 115.49 + WEEK 1 DAY 8 + n 132 132 + Mean (SD) 68.654 (18.064) -0.687 (27.807) + Median 68.573 -0.760 + Min - Max 16.87 - 115.60 -68.25 - 67.20 + WEEK 2 DAY 15 + n 132 132 + Mean (SD) 69.193 (18.056) -0.148 (28.606) + Median 69.304 -1.548 + Min - Max 29.62 - 120.50 -67.75 - 66.29 + WEEK 3 DAY 22 + n 132 132 + Mean (SD) 70.884 (20.280) 1.543 (27.285) + Median 70.124 0.139 + Min - Max 20.91 - 116.79 -64.51 - 72.52 + WEEK 4 DAY 29 + n 132 132 + Mean (SD) 71.020 (20.591) 1.679 (29.597) + Median 70.523 3.811 + Min - Max 10.35 - 117.30 -65.91 - 105.67 + WEEK 5 DAY 36 + n 132 132 + Mean (SD) 71.257 (18.563) 1.916 (29.591) + Median 73.292 1.735 + Min - Max 23.89 - 117.19 -58.23 - 68.86 + \s\n + Parameter: QT Duration + + ——————————————————————————————————————————————————————————————————————————————————————————————————— + Analysis Visit A: Drug X B: Placebo + Change from Change from + Value at Visit Baseline Value at Visit Baseline + (N=134) (N=134) (N=134) (N=134) + ——————————————————————————————————————————————————————————————————————————————————————————————————— + BASELINE + n 134 134 + Mean (SD) 336.834 (117.958) 351.004 (98.436) + Median 344.414 351.480 + Min - Max 86.98 - 665.40 98.90 - 641.92 + WEEK 1 DAY 8 + n 134 134 134 134 + Mean (SD) 342.574 (101.093) 5.741 (159.936) 363.946 (102.338) 12.943 (140.729) + Median 347.264 -1.779 356.539 13.730 + Min - Max 91.63 - 591.42 -346.44 - 452.75 114.92 - 656.45 -317.53 - 416.35 + WEEK 2 DAY 15 + n 134 134 134 134 + Mean (SD) 353.244 (93.926) 16.410 (162.103) 345.926 (96.783) -5.078 (152.509) + Median 351.099 16.722 346.831 -9.681 + Min - Max 138.01 - 587.30 -414.07 - 389.16 146.42 - 556.07 -440.28 - 364.76 + WEEK 3 DAY 22 + n 134 134 134 134 + Mean (SD) 370.115 (101.568) 33.282 (152.780) 343.412 (102.585) -7.592 (138.803) + Median 378.209 39.586 335.119 -15.888 + Min - Max 118.14 - 615.18 -391.72 - 520.09 63.37 - 566.51 -311.28 - 293.76 + WEEK 4 DAY 29 + n 134 134 134 134 + Mean (SD) 345.774 (95.970) 8.941 (145.647) 354.377 (108.286) 3.374 (142.390) + Median 340.134 5.576 346.699 -17.129 + Min - Max 110.12 - 616.58 -393.34 - 456.04 80.82 - 687.69 -439.90 - 364.80 + WEEK 5 DAY 36 + n 134 134 134 134 + Mean (SD) 358.903 (97.693) 22.069 (155.681) 338.648 (99.260) -12.356 (130.457) + Median 351.959 5.886 344.167 0.405 + Min - Max 88.38 - 661.12 -353.30 - 539.84 31.25 - 563.90 -338.85 - 352.75 + \s\n + Parameter: QT Duration + + ————————————————————————————————————————————————————————— + Analysis Visit C: Combination + Change from + Value at Visit Baseline + (N=132) (N=132) + ————————————————————————————————————————————————————————— + BASELINE + n 132 + Mean (SD) 352.598 (105.114) + Median 347.956 + Min - Max 105.68 - 628.14 + WEEK 1 DAY 8 + n 132 132 + Mean (SD) 359.424 (105.161) 6.826 (147.129) + Median 363.838 8.685 + Min - Max 51.91 - 611.88 -473.19 - 358.00 + WEEK 2 DAY 15 + n 132 132 + Mean (SD) 335.689 (98.605) -16.909 (138.448) + Median 320.957 -22.267 + Min - Max 104.91 - 562.34 -326.55 - 325.27 + WEEK 3 DAY 22 + n 132 132 + Mean (SD) 346.947 (94.965) -5.652 (144.651) + Median 352.154 9.113 + Min - Max 126.09 - 580.81 -412.11 - 410.01 + WEEK 4 DAY 29 + n 132 132 + Mean (SD) 341.358 (106.745) -11.240 (145.648) + Median 352.295 -11.868 + Min - Max 4.95 - 570.61 -480.94 - 330.67 + WEEK 5 DAY 36 + n 132 132 + Mean (SD) 349.303 (95.769) -3.296 (135.997) + Median 350.319 12.680 + Min - Max 119.02 - 581.83 -311.45 - 295.53 + \s\n + Parameter: RR Duration + + ——————————————————————————————————————————————————————————————————————————————————————————————————— + Analysis Visit A: Drug X B: Placebo + Change from Change from + Value at Visit Baseline Value at Visit Baseline + (N=134) (N=134) (N=134) (N=134) + ——————————————————————————————————————————————————————————————————————————————————————————————————— + BASELINE + n 134 134 + Mean (SD) 1028.419 (286.385) 1027.484 (324.000) + Median 1041.860 1047.268 + Min - Max 34.33 - 1783.71 5.29 - 1877.19 + WEEK 1 DAY 8 + n 134 134 134 134 + Mean (SD) 990.155 (318.736) -38.264 (446.403) 1061.587 (269.138) 34.103 (401.759) + Median 963.881 -86.501 1061.504 66.914 + Min - Max 110.82 - 2014.56 -1014.82 - 1389.40 276.83 - 1711.99 -942.16 - 993.82 + WEEK 2 DAY 15 + n 134 134 134 134 + Mean (SD) 1013.371 (304.135) -15.047 (425.807) 1109.402 (318.227) 81.918 (453.105) + Median 1040.693 40.485 1117.764 69.275 + Min - Max 164.19 - 1677.10 -1216.10 - 1053.15 160.73 - 2048.73 -1127.10 - 1148.61 + WEEK 3 DAY 22 + n 134 134 134 134 + Mean (SD) 1013.987 (304.990) -14.431 (406.529) 1118.345 (296.527) 90.861 (409.573) + Median 1027.232 -50.543 1134.596 52.029 + Min - Max 357.04 - 1798.65 -882.94 - 1080.26 97.14 - 1825.43 -887.06 - 1166.15 + WEEK 4 DAY 29 + n 134 134 134 134 + Mean (SD) 1033.309 (313.919) 4.890 (483.153) 1079.762 (298.940) 52.278 (429.253) + Median 1050.399 5.601 1051.613 69.554 + Min - Max 54.33 - 1979.43 -1345.93 - 1195.41 347.94 - 1762.04 -826.43 - 1191.83 + WEEK 5 DAY 36 + n 134 134 134 134 + Mean (SD) 1072.335 (282.901) 43.916 (379.048) 1058.452 (271.012) 30.968 (436.030) + Median 1067.330 55.872 1068.950 33.615 + Min - Max 352.97 - 2000.56 -1028.79 - 1418.57 208.83 - 1794.73 -978.97 - 1365.13 + \s\n + Parameter: RR Duration + + ————————————————————————————————————————————————————————— + Analysis Visit C: Combination + Change from + Value at Visit Baseline + (N=132) (N=132) + ————————————————————————————————————————————————————————— + BASELINE + n 132 + Mean (SD) 1074.623 (277.328) + Median 1080.866 + Min - Max 289.60 - 1617.06 + WEEK 1 DAY 8 + n 132 132 + Mean (SD) 1039.642 (284.389) -34.981 (406.037) + Median 1014.780 -97.826 + Min - Max 498.21 - 1937.47 -958.61 - 908.90 + WEEK 2 DAY 15 + n 132 132 + Mean (SD) 1045.209 (277.506) -29.414 (380.841) + Median 1034.637 -15.331 + Min - Max 252.84 - 1722.33 -859.27 - 871.54 + WEEK 3 DAY 22 + n 132 132 + Mean (SD) 1036.593 (268.521) -38.030 (421.484) + Median 1030.717 -60.720 + Min - Max 446.02 - 1713.38 -984.79 - 902.37 + WEEK 4 DAY 29 + n 132 132 + Mean (SD) 1027.549 (295.856) -47.074 (378.235) + Median 1023.360 -49.519 + Min - Max 341.62 - 2144.86 -1002.03 - 1048.66 + WEEK 5 DAY 36 + n 132 132 + Mean (SD) 1029.043 (271.211) -45.580 (405.528) + Median 1065.256 -34.395 + Min - Max 436.28 - 1794.07 -962.18 - 1329.88 # egt01 can handle n = 0 and outputs NE instead of infs and NAs diff --git a/tests/testthat/_snaps/lbt01.md b/tests/testthat/_snaps/lbt01.md index 0f2504e01..fa7927433 100644 --- a/tests/testthat/_snaps/lbt01.md +++ b/tests/testthat/_snaps/lbt01.md @@ -207,99 +207,36 @@ Baseline Value at Visit Baseline (N=134) (N=132) (N=132) ——————————————————————————————————————————————————————————————————————————————————————— - Alanine Aminotransferase Measurement - BASELINE - n 132 - Mean (SD) 20.451 (3.911) - Median 20.387 - Min - Max 8.82 - 28.72 - WEEK 1 DAY 8 - n 134 132 132 - Mean (SD) 0.068 (6.036) 20.553 (3.895) 0.102 (5.461) - Median -0.725 20.402 0.025 - Min - Max -12.29 - 17.41 9.87 - 30.70 -13.69 - 15.54 - WEEK 2 DAY 15 - n 134 132 132 - Mean (SD) -0.030 (6.263) 19.247 (3.592) -1.204 (5.485) - Median -0.371 19.608 -0.482 - Min - Max -18.37 - 14.39 8.11 - 26.68 -14.28 - 15.65 - WEEK 3 DAY 22 - n 134 132 132 - Mean (SD) -0.316 (5.604) 19.428 (3.944) -1.023 (5.550) - Median -0.178 18.838 -1.065 - Min - Max -18.52 - 15.00 10.20 - 28.49 -12.33 - 11.10 - WEEK 4 DAY 29 - n 134 132 132 - Mean (SD) -0.521 (6.293) 19.823 (3.995) -0.627 (5.311) - Median -1.186 19.884 -0.646 - Min - Max -16.58 - 17.23 7.76 - 29.31 -12.13 - 15.30 - WEEK 5 DAY 36 - n 134 132 132 - Mean (SD) -0.294 (6.315) 19.990 (4.169) -0.460 (5.570) - Median 0.728 20.503 -0.990 - Min - Max -19.04 - 12.64 7.41 - 27.78 -15.62 - 16.61 - C-Reactive Protein Measurement - BASELINE - n 132 - Mean (SD) 1.005 (0.210) - Median 0.996 - Min - Max 0.51 - 1.56 - WEEK 1 DAY 8 - n 134 132 132 - Mean (SD) 0.005 (0.289) 1.006 (0.234) 0.001 (0.327) - Median 0.015 1.017 -0.008 - Min - Max -0.78 - 0.93 0.44 - 1.53 -0.80 - 0.75 - WEEK 2 DAY 15 - n 134 132 132 - Mean (SD) 0.020 (0.267) 0.978 (0.206) -0.027 (0.278) - Median 0.021 0.967 -0.035 - Min - Max -0.55 - 0.68 0.27 - 1.51 -0.76 - 0.50 - WEEK 3 DAY 22 - n 134 132 132 - Mean (SD) -0.020 (0.266) 0.995 (0.191) -0.010 (0.301) - Median 0.004 0.987 -0.029 - Min - Max -0.77 - 0.75 0.50 - 1.57 -0.72 - 0.86 - WEEK 4 DAY 29 - n 134 132 132 - Mean (SD) -0.015 (0.278) 0.994 (0.190) -0.011 (0.289) - Median -0.032 1.004 0.018 - Min - Max -0.62 - 0.59 0.55 - 1.46 -0.82 - 0.82 - WEEK 5 DAY 36 - n 134 132 132 - Mean (SD) 0.019 (0.282) 0.976 (0.191) -0.029 (0.290) - Median 0.011 0.980 -0.037 - Min - Max -0.64 - 0.83 0.55 - 1.59 -0.84 - 0.79 - Immunoglobulin A Measurement - BASELINE - n 132 - Mean (SD) 2.015 (0.453) - Median 1.987 - Min - Max 0.80 - 3.00 - WEEK 1 DAY 8 - n 134 132 132 - Mean (SD) 0.069 (0.562) 2.038 (0.421) 0.022 (0.645) - Median 0.077 2.055 0.023 - Min - Max -1.27 - 1.78 0.81 - 3.05 -1.49 - 1.55 - WEEK 2 DAY 15 - n 134 132 132 - Mean (SD) 0.007 (0.583) 1.969 (0.374) -0.046 (0.602) - Median 0.047 1.978 -0.010 - Min - Max -1.48 - 1.38 0.97 - 2.75 -1.64 - 1.45 - WEEK 3 DAY 22 - n 134 132 132 - Mean (SD) 0.012 (0.577) 2.048 (0.391) 0.033 (0.602) - Median 0.039 2.056 0.013 - Min - Max -1.60 - 1.21 0.99 - 2.99 -1.81 - 1.23 - WEEK 4 DAY 29 - n 134 132 132 - Mean (SD) -0.032 (0.551) 1.979 (0.420) -0.037 (0.622) - Median 0.028 1.993 -0.068 - Min - Max -1.38 - 1.09 0.99 - 2.95 -1.35 - 1.59 - WEEK 5 DAY 36 - n 134 132 132 - Mean (SD) 0.031 (0.635) 1.965 (0.427) -0.050 (0.609) - Median 0.071 2.009 0.034 - Min - Max -1.38 - 1.64 0.62 - 2.88 -1.60 - 1.32 + BASELINE + n 132 + Mean (SD) 2.015 (0.453) + Median 1.987 + Min - Max 0.80 - 3.00 + WEEK 1 DAY 8 + n 134 132 132 + Mean (SD) 0.069 (0.562) 2.038 (0.421) 0.022 (0.645) + Median 0.077 2.055 0.023 + Min - Max -1.27 - 1.78 0.81 - 3.05 -1.49 - 1.55 + WEEK 2 DAY 15 + n 134 132 132 + Mean (SD) 0.007 (0.583) 1.969 (0.374) -0.046 (0.602) + Median 0.047 1.978 -0.010 + Min - Max -1.48 - 1.38 0.97 - 2.75 -1.64 - 1.45 + WEEK 3 DAY 22 + n 134 132 132 + Mean (SD) 0.012 (0.577) 2.048 (0.391) 0.033 (0.602) + Median 0.039 2.056 0.013 + Min - Max -1.60 - 1.21 0.99 - 2.99 -1.81 - 1.23 + WEEK 4 DAY 29 + n 134 132 132 + Mean (SD) -0.032 (0.551) 1.979 (0.420) -0.037 (0.622) + Median 0.028 1.993 -0.068 + Min - Max -1.38 - 1.09 0.99 - 2.95 -1.35 - 1.59 + WEEK 5 DAY 36 + n 134 132 132 + Mean (SD) 0.031 (0.635) 1.965 (0.427) -0.050 (0.609) + Median 0.071 2.009 0.034 + Min - Max -1.38 - 1.64 0.62 - 2.88 -1.60 - 1.32 # lbt01 functions with row_split_var return expected result with test data @@ -516,101 +453,36 @@ Baseline Value at Visit Baseline (N=134) (N=132) (N=132) ————————————————————————————————————————————————————————————————————————————————————————— - CHEMISTRY - Alanine Aminotransferase Measurement - BASELINE - n 132 - Mean (SD) 20.451 (3.911) - Median 20.387 - Min - Max 8.82 - 28.72 - WEEK 1 DAY 8 - n 134 132 132 - Mean (SD) 0.068 (6.036) 20.553 (3.895) 0.102 (5.461) - Median -0.725 20.402 0.025 - Min - Max -12.29 - 17.41 9.87 - 30.70 -13.69 - 15.54 - WEEK 2 DAY 15 - n 134 132 132 - Mean (SD) -0.030 (6.263) 19.247 (3.592) -1.204 (5.485) - Median -0.371 19.608 -0.482 - Min - Max -18.37 - 14.39 8.11 - 26.68 -14.28 - 15.65 - WEEK 3 DAY 22 - n 134 132 132 - Mean (SD) -0.316 (5.604) 19.428 (3.944) -1.023 (5.550) - Median -0.178 18.838 -1.065 - Min - Max -18.52 - 15.00 10.20 - 28.49 -12.33 - 11.10 - WEEK 4 DAY 29 - n 134 132 132 - Mean (SD) -0.521 (6.293) 19.823 (3.995) -0.627 (5.311) - Median -1.186 19.884 -0.646 - Min - Max -16.58 - 17.23 7.76 - 29.31 -12.13 - 15.30 - WEEK 5 DAY 36 - n 134 132 132 - Mean (SD) -0.294 (6.315) 19.990 (4.169) -0.460 (5.570) - Median 0.728 20.503 -0.990 - Min - Max -19.04 - 12.64 7.41 - 27.78 -15.62 - 16.61 - C-Reactive Protein Measurement - BASELINE - n 132 - Mean (SD) 1.005 (0.210) - Median 0.996 - Min - Max 0.51 - 1.56 - WEEK 1 DAY 8 - n 134 132 132 - Mean (SD) 0.005 (0.289) 1.006 (0.234) 0.001 (0.327) - Median 0.015 1.017 -0.008 - Min - Max -0.78 - 0.93 0.44 - 1.53 -0.80 - 0.75 - WEEK 2 DAY 15 - n 134 132 132 - Mean (SD) 0.020 (0.267) 0.978 (0.206) -0.027 (0.278) - Median 0.021 0.967 -0.035 - Min - Max -0.55 - 0.68 0.27 - 1.51 -0.76 - 0.50 - WEEK 3 DAY 22 - n 134 132 132 - Mean (SD) -0.020 (0.266) 0.995 (0.191) -0.010 (0.301) - Median 0.004 0.987 -0.029 - Min - Max -0.77 - 0.75 0.50 - 1.57 -0.72 - 0.86 - WEEK 4 DAY 29 - n 134 132 132 - Mean (SD) -0.015 (0.278) 0.994 (0.190) -0.011 (0.289) - Median -0.032 1.004 0.018 - Min - Max -0.62 - 0.59 0.55 - 1.46 -0.82 - 0.82 - WEEK 5 DAY 36 - n 134 132 132 - Mean (SD) 0.019 (0.282) 0.976 (0.191) -0.029 (0.290) - Median 0.011 0.980 -0.037 - Min - Max -0.64 - 0.83 0.55 - 1.59 -0.84 - 0.79 - IMMUNOLOGY - Immunoglobulin A Measurement - BASELINE - n 132 - Mean (SD) 2.015 (0.453) - Median 1.987 - Min - Max 0.80 - 3.00 - WEEK 1 DAY 8 - n 134 132 132 - Mean (SD) 0.069 (0.562) 2.038 (0.421) 0.022 (0.645) - Median 0.077 2.055 0.023 - Min - Max -1.27 - 1.78 0.81 - 3.05 -1.49 - 1.55 - WEEK 2 DAY 15 - n 134 132 132 - Mean (SD) 0.007 (0.583) 1.969 (0.374) -0.046 (0.602) - Median 0.047 1.978 -0.010 - Min - Max -1.48 - 1.38 0.97 - 2.75 -1.64 - 1.45 - WEEK 3 DAY 22 - n 134 132 132 - Mean (SD) 0.012 (0.577) 2.048 (0.391) 0.033 (0.602) - Median 0.039 2.056 0.013 - Min - Max -1.60 - 1.21 0.99 - 2.99 -1.81 - 1.23 - WEEK 4 DAY 29 - n 134 132 132 - Mean (SD) -0.032 (0.551) 1.979 (0.420) -0.037 (0.622) - Median 0.028 1.993 -0.068 - Min - Max -1.38 - 1.09 0.99 - 2.95 -1.35 - 1.59 - WEEK 5 DAY 36 - n 134 132 132 - Mean (SD) 0.031 (0.635) 1.965 (0.427) -0.050 (0.609) - Median 0.071 2.009 0.034 - Min - Max -1.38 - 1.64 0.62 - 2.88 -1.60 - 1.32 + BASELINE + n 132 + Mean (SD) 2.015 (0.453) + Median 1.987 + Min - Max 0.80 - 3.00 + WEEK 1 DAY 8 + n 134 132 132 + Mean (SD) 0.069 (0.562) 2.038 (0.421) 0.022 (0.645) + Median 0.077 2.055 0.023 + Min - Max -1.27 - 1.78 0.81 - 3.05 -1.49 - 1.55 + WEEK 2 DAY 15 + n 134 132 132 + Mean (SD) 0.007 (0.583) 1.969 (0.374) -0.046 (0.602) + Median 0.047 1.978 -0.010 + Min - Max -1.48 - 1.38 0.97 - 2.75 -1.64 - 1.45 + WEEK 3 DAY 22 + n 134 132 132 + Mean (SD) 0.012 (0.577) 2.048 (0.391) 0.033 (0.602) + Median 0.039 2.056 0.013 + Min - Max -1.60 - 1.21 0.99 - 2.99 -1.81 - 1.23 + WEEK 4 DAY 29 + n 134 132 132 + Mean (SD) -0.032 (0.551) 1.979 (0.420) -0.037 (0.622) + Median 0.028 1.993 -0.068 + Min - Max -1.38 - 1.09 0.99 - 2.95 -1.35 - 1.59 + WEEK 5 DAY 36 + n 134 132 132 + Mean (SD) 0.031 (0.635) 1.965 (0.427) -0.050 (0.609) + Median 0.071 2.009 0.034 + Min - Max -1.38 - 1.64 0.62 - 2.88 -1.60 - 1.32 # lbt01 can handle n = 0 and outputs NE instead of infs and NAs diff --git a/tests/testthat/_snaps/vst01.md b/tests/testthat/_snaps/vst01.md index df4b5781c..eb9a21a01 100644 --- a/tests/testthat/_snaps/vst01.md +++ b/tests/testthat/_snaps/vst01.md @@ -496,32 +496,41 @@ Value at Visit Baseline (N=132) (N=132) ——————————————————————————————————————————————————————————— - Weight - WEEK 1 DAY 8 - n 132 132 - Mean (SD) 49.572 (8.396) 0.196 (12.142) - Median 49.864 -0.451 - Min - Max 29.73 - 69.07 -31.02 - 32.60 - WEEK 2 DAY 15 - n 132 132 - Mean (SD) 49.741 (7.937) 0.364 (10.827) - Median 49.762 1.317 - Min - Max 28.09 - 73.67 -28.00 - 26.59 - WEEK 3 DAY 22 - n 132 132 - Mean (SD) 50.446 (8.084) 1.069 (10.807) - Median 50.805 -0.190 - Min - Max 27.81 - 70.85 -28.93 - 31.73 - WEEK 4 DAY 29 - n 132 132 - Mean (SD) 49.667 (7.509) 0.290 (10.415) - Median 49.608 -1.187 - Min - Max 30.79 - 77.45 -23.39 - 29.93 - WEEK 5 DAY 36 - n 132 132 - Mean (SD) 49.872 (7.400) 0.495 (10.871) - Median 49.590 -0.156 - Min - Max 28.74 - 67.93 -36.15 - 31.04 + SCREENING + n 132 0 + Mean (SD) 50.305 (9.057) NE (NE) + Median 49.745 NE + Min - Max 26.04 - 69.99 NE - NE + BASELINE + n 132 + Mean (SD) 49.377 (7.489) + Median 49.568 + Min - Max 29.39 - 65.05 + WEEK 1 DAY 8 + n 132 132 + Mean (SD) 49.572 (8.396) 0.196 (12.142) + Median 49.864 -0.451 + Min - Max 29.73 - 69.07 -31.02 - 32.60 + WEEK 2 DAY 15 + n 132 132 + Mean (SD) 49.741 (7.937) 0.364 (10.827) + Median 49.762 1.317 + Min - Max 28.09 - 73.67 -28.00 - 26.59 + WEEK 3 DAY 22 + n 132 132 + Mean (SD) 50.446 (8.084) 1.069 (10.807) + Median 50.805 -0.190 + Min - Max 27.81 - 70.85 -28.93 - 31.73 + WEEK 4 DAY 29 + n 132 132 + Mean (SD) 49.667 (7.509) 0.290 (10.415) + Median 49.608 -1.187 + Min - Max 30.79 - 77.45 -23.39 - 29.93 + WEEK 5 DAY 36 + n 132 132 + Mean (SD) 49.872 (7.400) 0.495 (10.871) + Median 49.590 -0.156 + Min - Max 28.74 - 67.93 -36.15 - 31.04 # run vst01 works as expected @@ -1021,30 +1030,39 @@ Value at Visit Baseline (N=132) (N=132) ——————————————————————————————————————————————————————————— - Weight - WEEK 1 DAY 8 - n 132 132 - Mean (SD) 49.572 (8.396) 0.196 (12.142) - Median 49.864 -0.451 - Min - Max 29.73 - 69.07 -31.02 - 32.60 - WEEK 2 DAY 15 - n 132 132 - Mean (SD) 49.741 (7.937) 0.364 (10.827) - Median 49.762 1.317 - Min - Max 28.09 - 73.67 -28.00 - 26.59 - WEEK 3 DAY 22 - n 132 132 - Mean (SD) 50.446 (8.084) 1.069 (10.807) - Median 50.805 -0.190 - Min - Max 27.81 - 70.85 -28.93 - 31.73 - WEEK 4 DAY 29 - n 132 132 - Mean (SD) 49.667 (7.509) 0.290 (10.415) - Median 49.608 -1.187 - Min - Max 30.79 - 77.45 -23.39 - 29.93 - WEEK 5 DAY 36 - n 132 132 - Mean (SD) 49.872 (7.400) 0.495 (10.871) - Median 49.590 -0.156 - Min - Max 28.74 - 67.93 -36.15 - 31.04 + SCREENING + n 132 0 + Mean (SD) 50.305 (9.057) NE (NE) + Median 49.745 NE + Min - Max 26.04 - 69.99 NE - NE + BASELINE + n 132 + Mean (SD) 49.377 (7.489) + Median 49.568 + Min - Max 29.39 - 65.05 + WEEK 1 DAY 8 + n 132 132 + Mean (SD) 49.572 (8.396) 0.196 (12.142) + Median 49.864 -0.451 + Min - Max 29.73 - 69.07 -31.02 - 32.60 + WEEK 2 DAY 15 + n 132 132 + Mean (SD) 49.741 (7.937) 0.364 (10.827) + Median 49.762 1.317 + Min - Max 28.09 - 73.67 -28.00 - 26.59 + WEEK 3 DAY 22 + n 132 132 + Mean (SD) 50.446 (8.084) 1.069 (10.807) + Median 50.805 -0.190 + Min - Max 27.81 - 70.85 -28.93 - 31.73 + WEEK 4 DAY 29 + n 132 132 + Mean (SD) 49.667 (7.509) 0.290 (10.415) + Median 49.608 -1.187 + Min - Max 30.79 - 77.45 -23.39 - 29.93 + WEEK 5 DAY 36 + n 132 132 + Mean (SD) 49.872 (7.400) 0.495 (10.871) + Median 49.590 -0.156 + Min - Max 28.74 - 67.93 -36.15 - 31.04 diff --git a/tests/testthat/test-egt01.R b/tests/testthat/test-egt01.R index 29eb953ae..324ca870b 100644 --- a/tests/testthat/test-egt01.R +++ b/tests/testthat/test-egt01.R @@ -4,7 +4,7 @@ test_that("egt01 functions with default argument value return expected result wi pre_data <- egt01_pre(syn_data) raw_res <- egt01_main(pre_data) res <- cfbt01_post(raw_res) - expect_snapshot(res) + expect_snapshot(cat(export_as_txt(res, lpp = 100))) }) # egt01 ---- diff --git a/tests/testthat/test-empty_report.R b/tests/testthat/test-empty_report.R index af3584653..1955b1134 100644 --- a/tests/testthat/test-empty_report.R +++ b/tests/testthat/test-empty_report.R @@ -47,7 +47,7 @@ test_that("tlg functions return null reports when domain table is empty", { res <- run(dtht01, dat_empty) expect_identical(res, empty_report) - res <- run(egt01, dat_empty, page_by = FALSE) + res <- run(egt01, dat_empty, page_var = NULL) expect_identical(res, empty_report) res <- run(egt02_1, dat_empty) @@ -71,7 +71,7 @@ test_that("tlg functions return null reports when domain table is empty", { res <- run(ext01, dat_empty, summaryvars = c("AVAL", "AVALCAT1")) expect_identical(res, empty_report) - res <- run(lbt01, dat_empty, page_by = FALSE) + res <- run(lbt01, dat_empty, page_var = NULL) expect_identical(res, empty_report) res <- run(lbt05, dat_empty, prune_0 = TRUE) @@ -83,7 +83,7 @@ test_that("tlg functions return null reports when domain table is empty", { res <- run(pdt01, dat_empty) expect_identical(res, empty_report) - res <- run(vst01, dat_empty, page_by = FALSE) + res <- run(vst01, dat_empty, page_var = NULL) expect_identical(res, empty_report) res <- run(vst02_1, dat_empty) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 27de2f95a..cde3c195d 100755 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,59 +1,47 @@ # h_pad_or_round ---- test_that("h_format_dec works as exected", { - fun <- expect_silent(h_format_dec(10, "%f")) + fun <- expect_silent(h_format_dec(10, "%s")) res <- fun(123.1234) expect_identical(res, "123.1234000000") - fun <- expect_silent(h_format_dec(0, "%f")) + fun <- expect_silent(h_format_dec(0, "%s")) res <- fun(123.1234) expect_identical(res, "123") - fun <- expect_silent(h_format_dec(1, "%f")) + fun <- expect_silent(h_format_dec(1, "%s")) res <- fun(123.06) expect_identical(res, "123.1") - fun <- expect_silent(h_format_dec(3, "%f")) + fun <- expect_silent(h_format_dec(3, "%s")) res <- fun(123) expect_identical(res, "123.000") - fun <- expect_silent(h_format_dec(0, "%f")) + fun <- expect_silent(h_format_dec(0, "%s")) res <- fun(123) expect_identical(res, "123") - fun <- expect_silent(h_format_dec(0, "%f")) + fun <- expect_silent(h_format_dec(0, "%s")) res <- fun(0.9) expect_identical(res, "1") }) test_that("h_format_dec works as expected with more than one value", { - fun <- h_format_dec(3, "%f - %f") + fun <- h_format_dec(c(3, 3), "%s - %s") res <- fun(c(123, 222)) expect_identical(res, "123.000 - 222.000") - fun <- h_format_dec(3, "%f /// %f /// %f") + fun <- h_format_dec(rep(3, 3), "%s /// %s /// %s") res <- fun(c(123, 222.2, 555.12345)) expect_identical(res, "123.000 /// 222.200 /// 555.123") }) -test_that("h_format_dec works returns null with NA format", { - fun <- h_format_dec(3) - expect_null(fun) -}) - test_that("h_format_dec works as expected with NA digits", { - fun <- h_format_dec(format = "%f - %f") + fun <- h_format_dec(format = "%s - %s", digits = rep(NA, 2)) res <- fun(c(123, 222.21)) - expect_identical(res, "123.000000 - 222.210000") + expect_identical(res, "") }) -test_that("h_format_dec works as expected with NA digits", { - fun <- h_format_dec(3, format = "%f - %.6f") - res <- fun(c(123, 222.21)) - expect_identical(res, "123.000 - 222.210000") -}) - - # fuse_sequentially ---- test_that("fuse_sequentially works", {