Skip to content

Commit

Permalink
Add nested argument to all analyze wrapper functions (#1009)
Browse files Browse the repository at this point in the history
Closes #999
  • Loading branch information
edelarua authored Jul 24, 2023
1 parent 3ee8fca commit 4a2675b
Show file tree
Hide file tree
Showing 56 changed files with 187 additions and 10 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Added `ylim` argument to `g_km` to allow the user to set custom limits for the y-axis.
* Added assertion to `g_km` which checks whether there is one arm present in the data when `annot_coxph` is true.
* Added `flag_labels` argument to `s_count_patients_with_flags` to enable more label handling options in `count_patients_by_flags`.
* Added the `nested` argument to `analyze` wrapper functions `count_abnormal`, `count_abnormal_by_baseline`, `count_abnormal_by_marked`, `count_abnormal_by_worst_grade`, `count_abnormal_lab_worsen_by_baseline`, `count_cumulative`, `count_missed_doses`, `count_occurrences`, `count_occurrences_by_grade`, `count_patients_with_event`, `count_patients_with_flags`, `count_values`, `estimate_multinomial_response`, `estimate_proportion`, `estimate_incidence_rate`, `estimate_odds_ratio`, `estimate_proportion_diff`, `test_proportion_diff`, `summarize_ancova`, `summarize_change`, `summarize_glm_count`, `analyze_num_patients`, `coxph_pairwise`, `surv_time`, and `surv_timepoint`.

### Miscellaneous
* Started deprecation cycle for `summarize_vars` and `control_summarize_vars`. Renamed into `analyze_vars` and `control_analyze_vars` to reflect underlying `rtables` machinery while keeping backward compatibility with aliases.
Expand Down
2 changes: 2 additions & 0 deletions R/abnormal.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ a_count_abnormal <- make_afun(
#' @export
count_abnormal <- function(lyt,
var,
nested = TRUE,
...,
table_names = var,
.stats = NULL,
Expand All @@ -161,6 +162,7 @@ count_abnormal <- function(lyt,
lyt = lyt,
vars = var,
afun = afun,
nested = nested,
table_names = table_names,
extra_args = list(...),
show_labels = "hidden"
Expand Down
2 changes: 2 additions & 0 deletions R/abnormal_by_baseline.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ a_count_abnormal_by_baseline <- make_afun(
count_abnormal_by_baseline <- function(lyt,
var,
abnormal,
nested = TRUE,
...,
table_names = abnormal,
.stats = NULL,
Expand All @@ -206,6 +207,7 @@ count_abnormal_by_baseline <- function(lyt,
vars = var,
var_labels = names(abn),
afun = afun,
nested = nested,
table_names = table_names[i],
extra_args = c(list(abnormal = abn), list(...)),
show_labels = "visible"
Expand Down
2 changes: 2 additions & 0 deletions R/abnormal_by_marked.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ a_count_abnormal_by_marked <- make_afun(
#' @export
count_abnormal_by_marked <- function(lyt,
var,
nested = TRUE,
...,
.stats = NULL,
.formats = NULL,
Expand All @@ -216,6 +217,7 @@ count_abnormal_by_marked <- function(lyt,
lyt = lyt,
vars = var,
afun = afun,
nested = nested,
show_labels = "hidden",
extra_args = c(list(...))
)
Expand Down
2 changes: 2 additions & 0 deletions R/abnormal_by_worst_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ a_count_abnormal_by_worst_grade <- make_afun( # nolint
#' @export
count_abnormal_by_worst_grade <- function(lyt,
var,
nested = TRUE,
...,
.stats = NULL,
.formats = NULL,
Expand All @@ -181,6 +182,7 @@ count_abnormal_by_worst_grade <- function(lyt,
lyt = lyt,
vars = var,
afun = afun,
nested = nested,
extra_args = list(...),
show_labels = "hidden"
)
Expand Down
2 changes: 2 additions & 0 deletions R/abnormal_by_worst_grade_worsen.R
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ a_count_abnormal_lab_worsen_by_baseline <- make_afun( # nolint
#' @export
count_abnormal_lab_worsen_by_baseline <- function(lyt, # nolint
var,
nested = TRUE,
...,
table_names = NULL,
.stats = NULL,
Expand All @@ -376,6 +377,7 @@ count_abnormal_lab_worsen_by_baseline <- function(lyt, # nolint
lyt = lyt,
vars = var,
afun = afun,
nested = nested,
extra_args = list(...),
show_labels = "hidden"
)
Expand Down
4 changes: 2 additions & 2 deletions R/argument_convention.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#' @param lyt (`layout`)\cr input layout where analyses will be added to.
#' @param na.rm (`flag`)\cr whether `NA` values should be removed from `x` prior to analysis.
#' @param na_level (`string`)\cr string used to replace all `NA` or empty values in the output.
#' @param nested (`flag`)\cr whether this layout instruction be applied within the existing layout structure _if
#' possible_ (`TRUE`, the default) or as a new top-level element (`FALSE`). Ignored if it would nest a split
#' @param nested (`flag`)\cr whether this layout instruction should be applied within the existing layout structure _if
#' possible_ (`TRUE`, the default) or as a new top-level element (`FALSE`). Ignored if it would nest a split.
#' underneath analyses, which is not allowed.
#' @param newpage (`flag`)\cr whether the plot should be drawn on a new page.
#' Only considered if `draw = TRUE` is used.
Expand Down
2 changes: 2 additions & 0 deletions R/count_cumulative.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ count_cumulative <- function(lyt,
vars,
var_labels = vars,
show_labels = "visible",
nested = TRUE,
...,
table_names = vars,
.stats = NULL,
Expand All @@ -172,6 +173,7 @@ count_cumulative <- function(lyt,
table_names = table_names,
var_labels = var_labels,
show_labels = show_labels,
nested = nested,
extra_args = list(...)
)
}
2 changes: 2 additions & 0 deletions R/count_missed_doses.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ count_missed_doses <- function(lyt,
vars,
var_labels = vars,
show_labels = "visible",
nested = TRUE,
...,
table_names = vars,
.stats = NULL,
Expand All @@ -133,6 +134,7 @@ count_missed_doses <- function(lyt,
var_labels = var_labels,
table_names = table_names,
show_labels = show_labels,
nested = nested,
extra_args = list(...)
)
}
2 changes: 2 additions & 0 deletions R/count_occurrences.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ count_occurrences <- function(lyt,
vars,
var_labels = vars,
show_labels = "hidden",
nested = TRUE,
...,
table_names = vars,
.stats = "count_fraction",
Expand All @@ -191,6 +192,7 @@ count_occurrences <- function(lyt,
var_labels = var_labels,
show_labels = show_labels,
table_names = table_names,
nested = nested,
extra_args = list(...)
)
}
2 changes: 2 additions & 0 deletions R/count_occurrences_by_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ count_occurrences_by_grade <- function(lyt,
var,
var_labels = var,
show_labels = "default",
nested = TRUE,
...,
table_names = var,
.stats = NULL,
Expand All @@ -281,6 +282,7 @@ count_occurrences_by_grade <- function(lyt,
show_labels = show_labels,
afun = afun,
table_names = table_names,
nested = nested,
extra_args = list(...)
)
}
Expand Down
2 changes: 2 additions & 0 deletions R/count_patients_with_event.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ a_count_patients_with_event <- make_afun(
#' @export
count_patients_with_event <- function(lyt,
vars,
nested = TRUE,
...,
table_names = vars,
.stats = "count_fraction",
Expand All @@ -162,6 +163,7 @@ count_patients_with_event <- function(lyt,
lyt,
vars,
afun = afun,
nested = nested,
extra_args = list(...),
show_labels = ifelse(length(vars) > 1, "visible", "hidden"),
table_names = table_names
Expand Down
2 changes: 2 additions & 0 deletions R/count_patients_with_flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ count_patients_with_flags <- function(lyt,
var,
var_labels = var,
show_labels = "hidden",
nested = TRUE,
...,
table_names = paste0("tbl_flags_", var),
.stats = "count_fraction",
Expand All @@ -177,6 +178,7 @@ count_patients_with_flags <- function(lyt,
show_labels = show_labels,
afun = afun,
table_names = table_names,
nested = nested,
extra_args = list(...)
)

Expand Down
2 changes: 2 additions & 0 deletions R/count_values.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ a_count_values <- make_afun(
count_values <- function(lyt,
vars,
values,
nested = TRUE,
...,
table_names = vars,
.stats = "count_fraction",
Expand All @@ -139,6 +140,7 @@ count_values <- function(lyt,
lyt,
vars,
afun = afun,
nested = nested,
extra_args = c(list(values = values), list(...)),
show_labels = ifelse(length(vars) > 1, "visible", "hidden"),
table_names = table_names
Expand Down
2 changes: 2 additions & 0 deletions R/estimate_multinomial_rsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ a_length_proportion <- make_afun(
#' @export
estimate_multinomial_response <- function(lyt,
var,
nested = TRUE,
...,
show_labels = "hidden",
table_names = var,
Expand All @@ -169,6 +170,7 @@ estimate_multinomial_response <- function(lyt,
afun = afun,
show_labels = show_labels,
table_names = table_names,
nested = nested,
extra_args = list(...)
)
}
2 changes: 2 additions & 0 deletions R/estimate_proportion.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ a_proportion <- make_afun(
#' @export
estimate_proportion <- function(lyt,
vars,
nested = TRUE,
...,
show_labels = "hidden",
table_names = vars,
Expand All @@ -180,6 +181,7 @@ estimate_proportion <- function(lyt,
lyt,
vars,
afun = afun,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand Down
2 changes: 2 additions & 0 deletions R/incidence_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ a_incidence_rate <- make_afun(
#' @export
estimate_incidence_rate <- function(lyt,
vars,
nested = TRUE,
...,
show_labels = "hidden",
table_names = vars,
Expand All @@ -156,6 +157,7 @@ estimate_incidence_rate <- function(lyt,
show_labels = show_labels,
table_names = table_names,
afun = afun,
nested = nested,
extra_args = list(...)
)
}
Expand Down
2 changes: 2 additions & 0 deletions R/odds_ratio.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ a_odds_ratio <- make_afun(
#' @export
estimate_odds_ratio <- function(lyt,
vars,
nested = TRUE,
...,
show_labels = "hidden",
table_names = vars,
Expand All @@ -207,6 +208,7 @@ estimate_odds_ratio <- function(lyt,
lyt,
vars,
afun = afun,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand Down
2 changes: 2 additions & 0 deletions R/prop_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ a_proportion_diff <- make_afun(
#' @export
estimate_proportion_diff <- function(lyt,
vars,
nested = TRUE,
...,
var_labels = vars,
show_labels = "hidden",
Expand All @@ -212,6 +213,7 @@ estimate_proportion_diff <- function(lyt,
vars,
afun = afun,
var_labels = var_labels,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand Down
2 changes: 2 additions & 0 deletions R/prop_diff_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ a_test_proportion_diff <- make_afun(
#' @export
test_proportion_diff <- function(lyt,
vars,
nested = TRUE,
...,
var_labels = vars,
show_labels = "hidden",
Expand All @@ -156,6 +157,7 @@ test_proportion_diff <- function(lyt,
vars,
afun = afun,
var_labels = var_labels,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand Down
2 changes: 2 additions & 0 deletions R/summarize_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ a_ancova <- make_afun(
summarize_ancova <- function(lyt,
vars,
var_labels,
nested = TRUE,
...,
show_labels = "visible",
table_names = vars,
Expand All @@ -270,6 +271,7 @@ summarize_ancova <- function(lyt,
show_labels = show_labels,
table_names = table_names,
afun = afun,
nested = nested,
extra_args = list(...)
)
}
2 changes: 2 additions & 0 deletions R/summarize_change.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ a_change_from_baseline <- make_afun(
#' @export
summarize_change <- function(lyt,
vars,
nested = TRUE,
...,
table_names = vars,
.stats = c("n", "mean_sd", "median", "range"),
Expand All @@ -138,6 +139,7 @@ summarize_change <- function(lyt,
lyt,
vars,
afun = afun,
nested = nested,
extra_args = list(...),
table_names = table_names
)
Expand Down
2 changes: 2 additions & 0 deletions R/summarize_glm_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ a_glm_count <- make_afun(
summarize_glm_count <- function(lyt,
vars,
var_labels,
nested = TRUE,
...,
show_labels = "visible",
table_names = vars,
Expand All @@ -422,6 +423,7 @@ summarize_glm_count <- function(lyt,
show_labels = show_labels,
table_names = table_names,
afun = afun,
nested = nested,
extra_args = list(...)
)
}
2 changes: 2 additions & 0 deletions R/summarize_num_patients.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ summarize_num_patients <- function(lyt,
#' @export
analyze_num_patients <- function(lyt,
vars,
nested = TRUE,
.stats = NULL,
.formats = NULL,
.labels = c(
Expand Down Expand Up @@ -232,6 +233,7 @@ analyze_num_patients <- function(lyt,
afun = afun,
lyt = lyt,
vars = vars,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
indent_mod = .indent_mods
Expand Down
2 changes: 2 additions & 0 deletions R/survival_coxph_pairwise.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ a_coxph_pairwise <- make_afun(
#' @export
coxph_pairwise <- function(lyt,
vars,
nested = TRUE,
...,
var_labels = "CoxPH",
show_labels = "visible",
Expand All @@ -187,6 +188,7 @@ coxph_pairwise <- function(lyt,
show_labels = show_labels,
table_names = table_names,
afun = afun,
nested = nested,
extra_args = list(...)
)
}
Loading

0 comments on commit 4a2675b

Please sign in to comment.