diff --git a/main/coverage-report/index.html b/main/coverage-report/index.html index 5d6ee6d8c7..fe8e1c8274 100644 --- a/main/coverage-report/index.html +++ b/main/coverage-report/index.html @@ -107,8 +107,8 @@
checkmate::assert_character(method_groups)
checkmate::assert_character(stats_in, null.ok = TRUE)
checkmate::assert_flag(add_pval)
if (any(method_groups == "analyze_vars")) {
type_tmp <- ifelse(any(grepl("counts", method_groups)), "counts", "numeric") # for pval checks
out <- NULL
for (mgi in method_groups) {
out_tmp <- if (mgi %in% names(tern_default_stats)) {
tern_default_stats[[mgi]]
out <- unique(c(out, out_tmp))
if (!is.null(stats_in) && any(grepl("^pval", stats_in))) {
if (isTRUE(add_pval)) {
if (!is.null(stats_in)) {
if (length(out) == 0) {
out
checkmate::assert_character(stats, min.len = 1)
if (checkmate::test_list(formats_in, null.ok = TRUE)) {
checkmate::assert_character(formats_in, null.ok = TRUE)
which_fmt <- match(stats, names(tern_default_formats))
ret <- vector("list", length = length(stats)) # Returning a list is simpler
ret[!is.na(which_fmt)] <- tern_default_formats[which_fmt[!is.na(which_fmt)]]
out <- setNames(ret, stats)
if (!is.null(formats_in)) {
common_names <- intersect(names(out), names(formats_in))
out[common_names] <- formats_in[common_names]
out
checkmate::assert_character(stats, min.len = 1, null.ok = TRUE)
checkmate::assert_character(row_nms, null.ok = TRUE)
if (checkmate::test_list(labels_in, null.ok = TRUE)) {
checkmate::assert_character(labels_in, null.ok = TRUE)
if (!is.null(row_nms)) {
which_lbl <- match(stats, names(tern_default_labels))
ret <- vector("character", length = length(stats)) # it needs to be a character vector
ret[!is.na(which_lbl)] <- tern_default_labels[which_lbl[!is.na(which_lbl)]]
out <- setNames(ret, stats)
if (!is.null(labels_in)) {
common_names <- intersect(names(out), names(labels_in))
out[common_names] <- labels_in[common_names]
out
checkmate::assert_character(stats, min.len = 1)
checkmate::assert_character(row_nms, null.ok = TRUE)
if (checkmate::test_list(indents_in, null.ok = TRUE)) {
checkmate::assert_list(indents_in, null.ok = TRUE)
if (is.null(names(indents_in)) && length(indents_in) == 1) {
if (!is.null(row_nms)) {
ret <- rep(0L, length(stats))
out <- setNames(ret, stats)
if (!is.null(indents_in)) {
out
if ("conf_level" %in% names(control)) {
labels_default <- sapply(
names(labels_default),
function(x) {
if (!x %in% names(labels_custom)) {
gsub(labels_default[[x]], pattern = "[0-9]+% CI", replacement = f_conf_level(control[["conf_level"]]))
if ("quantiles" %in% names(control) && "quantiles" %in% names(labels_default) &&
!"quantiles" %in% names(labels_custom)) { # nolint
labels_default["quantiles"] <- gsub(
"[0-9]+% and [0-9]+", paste0(control[["quantiles"]][1] * 100, "% and ", control[["quantiles"]][2] * 100, ""),
labels_default["quantiles"]
if ("test_mean" %in% names(control) && "mean_pval" %in% names(labels_default) &&
!"mean_pval" %in% names(labels_custom)) { # nolint
labels_default
is_auto_fmt <- vapply(.formats, function(ii) is.character(ii) && ii == "auto", logical(1))
if (any(is_auto_fmt)) {
.formats
getOption("tern_default_na_str", default = NA_character_)
checkmate::assert_numeric(x)
if (finite) {
} else if (na.rm) {
x <- x[!is.na(x)]
if (length(x) == 0) {
rval <- c(NA, NA)
mode(rval) <- typeof(x)
rval <- c(min(x, na.rm = FALSE), max(x, na.rm = FALSE))
return(rval)
assert_proportion_value(conf_level)
paste0(conf_level * 100, "% CI")
conf_type <- match.arg(conf_type)
checkmate::assert_numeric(quantiles, lower = 0, upper = 1, len = 2, unique = TRUE, sorted = TRUE)
nullo <- lapply(quantiles, assert_proportion_value)
assert_proportion_value(conf_level)
list(conf_level = conf_level, conf_type = conf_type, quantiles = quantiles)
checkmate::assert_string(.var)
assert_df_with_variables(df, list(tte = .var, is_event = is_event))
checkmate::assert_numeric(df[[.var]], min.len = 1, any.missing = FALSE)
checkmate::assert_logical(df[[is_event]], min.len = 1, any.missing = FALSE)
conf_type <- control$conf_type
conf_level <- control$conf_level
quantiles <- control$quantiles
formula <- stats::as.formula(paste0("survival::Surv(", .var, ", ", is_event, ") ~ 1"))
srv_fit <- survival::survfit(
formula = formula,
data = df,
conf.int = conf_level,
conf.type = conf_type
srv_tab <- summary(srv_fit, extend = TRUE)$table
srv_qt_tab <- stats::quantile(srv_fit, probs = quantiles)$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)
list(
median = formatters::with_label(unname(srv_tab["median"]), "Median"),
median_ci = formatters::with_label(
unname(srv_tab[paste0(srv_fit$conf.int, c("LCL", "UCL"))]), f_conf_level(conf_level)
quantiles = formatters::with_label(
unname(srv_qt_tab), paste0(quantiles[1] * 100, "% and ", quantiles[2] * 100, "%-ile")
range_censor = formatters::with_label(range_censor, "Range (censored)"),
range_event = formatters::with_label(range_event, "Range (event)"),
range = formatters::with_label(range, "Range")
x_stats <- s_surv_time(
df = df, .var = .var, is_event = is_event, control = control
rng_censor_lwr <- x_stats[["range_censor"]][1]
rng_censor_upr <- x_stats[["range_censor"]][2]
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)")
lbls_custom <- .labels
.formats <- c(.formats, fmts[setdiff(names(fmts), names(.formats))])
.labels <- c(.labels, lbls[setdiff(names(lbls), names(lbls_custom))])
.stats <- get_stats("surv_time", stats_in = .stats)
.formats <- get_formats_from_stats(.stats, .formats)
.labels <- get_labels_from_stats(.stats, .labels) %>% labels_use_control(control, lbls_custom)
.indent_mods <- get_indents_from_stats(.stats, .indent_mods)
x_stats <- x_stats[.stats]
.formats <- apply_auto_formatting(.formats, x_stats, .df_row, .var)
cell_fns <- setNames(vector("list", length = length(x_stats)), .labels)
if ("range" %in% names(x_stats) && ref_fn_censor) {
if (x_stats[["range"]][1] == rng_censor_lwr && x_stats[["range"]][2] == rng_censor_upr) {+
if (identical(x_stats[["range"]][1], rng_censor_lwr) && identical(x_stats[["range"]][2], rng_censor_upr)) {
cell_fns[[.labels[["range"]]]] <- "Censored observations: range minimum & maximum"
} else if (x_stats[["range"]][1] == rng_censor_lwr) {+
} else if (identical(x_stats[["range"]][1], rng_censor_lwr)) {
} else if (x_stats[["range"]][2] == rng_censor_upr) {+
} else if (identical(x_stats[["range"]][2], rng_censor_upr)) {
in_rows(
.list = x_stats,
.formats = .formats,
.names = .labels,
.labels = .labels,
.indent_mods = .indent_mods,
.format_na_strs = na_str,
.cell_footnotes = cell_fns
x <- Filter(Negate(is.null), x)
res <- checkmate::check_list(x,
names = "named",
min.len = 1,
any.missing = FALSE,
types = "character"
if (isTRUE(res)) {
res <- checkmate::check_character(unlist(x), min.chars = 1)
return(res)
checkmate::assert_data_frame(df)
assert_list_of_variables(variables)
err_flag <- all(unlist(variables) %in% colnames(df))
checkmate::assert_flag(err_flag)
if (isFALSE(err_flag)) {
if (!is.null(na_level)) {
return(TRUE)
checkmate::assert_number(x, lower = 0, upper = 1)
checkmate::assert_flag(include_boundaries)
if (isFALSE(include_boundaries)) {
checkmate::assert_true(x > 0)
checkmate::assert_true(x < 1)