Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nested argument to all analyze wrapper functions #1009

Merged
merged 6 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3,7 +3,7 @@
#' @description `r lifecycle::badge("stable")`
#'
#' Primary analysis variable `.var` indicates the abnormal range result (`character` or `factor`)
#' and additional analysis variables are `id` (`character` or `factor`) and `baseline` (`character` or

Check notice on line 6 in R/abnormal.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal.R#L6

"additional" is wordy or unneeded
#' `factor`). For each direction specified in `abnormal` (e.g. high or low) count patients in the
#' numerator and denominator as follows:
#' * `num` : The number of patients with this abnormality recorded while on treatment.
Expand All @@ -15,8 +15,8 @@
#' for example, `abnormal = list(Low = c("LOW", "LOW LOW"), High = c("HIGH", "HIGH HIGH"))`.
#'
#' @note
#' * `count_abnormal()` only works with a single variable containing multiple abnormal levels.

Check notice on line 18 in R/abnormal.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal.R#L18

"only" can weaken meaning

Check notice on line 18 in R/abnormal.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal.R#L18

"multiple" is wordy or unneeded
#' * `df` should be filtered to include only post-baseline records.

Check notice on line 19 in R/abnormal.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal.R#L19

"only" can weaken meaning
#' * the denominator includes patients that might have other abnormal levels at baseline,
#' and patients with missing baseline. Patients with these abnormalities at
#' baseline can be optionally excluded from numerator and denominator.
Expand Down Expand Up @@ -44,7 +44,7 @@
#' stringsAsFactors = FALSE
#' )
#'
#' # Select only post-baseline records.

Check notice on line 47 in R/abnormal.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal.R#L47

"only" can weaken meaning
#' df <- df %>%
#' filter(ONTRTFL == "Y")
#' @keywords internal
Expand Down Expand Up @@ -103,7 +103,7 @@
)

#' @describeIn abnormal Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 106 in R/abnormal.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal.R#L106

"additional" is wordy or unneeded
#'
#' @return
#' * `count_abnormal()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -125,7 +125,7 @@
#' stringsAsFactors = FALSE
#' )
#'
#' # Select only post-baseline records.

Check notice on line 128 in R/abnormal.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal.R#L128

"only" can weaken meaning
#' df2 <- df2 %>%
#' filter(ONTRTFL == "Y")
#'
Expand All @@ -140,6 +140,7 @@
#' @export
count_abnormal <- function(lyt,
var,
nested = TRUE,
...,
table_names = var,
.stats = NULL,
Expand All @@ -161,6 +162,7 @@
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 @@ -2,7 +2,7 @@
#'
#' @description `r lifecycle::badge("stable")`
#'
#' Primary analysis variable `.var` indicates the abnormal range result (`character` or `factor`), and additional

Check notice on line 5 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L5

"additional" is wordy or unneeded
#' analysis variables are `id` (`character` or `factor`) and `baseline` (`character` or `factor`). For each
#' direction specified in `abnormal` (e.g. high or low) we condition on baseline range result and count
#' patients in the numerator and denominator as follows:
Expand All @@ -20,8 +20,8 @@
#' @param abnormal (`character`)\cr identifying the abnormal range level(s) in `.var`.
#'
#' @note
#' * `df` should be filtered to include only post-baseline records.

Check notice on line 23 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L23

"only" can weaken meaning
#' * If the baseline variable or analysis variable contains `NA`, it is expected that `NA` has been

Check notice on line 24 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L24

"it is" is wordy or unneeded
#' conveyed to `na_level` appropriately beforehand with [df_explicit_na()] or [explicit_na()].
#'
#' @seealso Relevant description function [d_count_abnormal_by_baseline()].
Expand Down Expand Up @@ -57,7 +57,7 @@

#' @describeIn abnormal_by_baseline Statistics function for a single `abnormal` level.
#'
#' @param na_level (`string`)\cr the explicit `na_level` argument you used in the pre-processing steps (maybe with

Check notice on line 60 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L60

"maybe" can weaken meaning
#' [df_explicit_na()]). The default is `"<Missing>"`.
#'
#' @return
Expand Down Expand Up @@ -87,7 +87,7 @@
assert_valid_factor(df[[.var]], any.missing = FALSE)
assert_valid_factor(df[[variables$baseline]], any.missing = FALSE)

# Keep only records with valid analysis value.

Check notice on line 90 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L90

"only" can weaken meaning
df <- df[df[[.var]] != na_level, ]

anl <- data.frame(
Expand All @@ -103,7 +103,7 @@
total_denom <- length(unique(anl$id))
total_num <- length(unique(anl$id[anl$var == abnormal]))

# Baseline NA records are counted only in total rows.

Check notice on line 106 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L106

"only" can weaken meaning
anl <- anl[anl$baseline != na_level, ]

# Abnormal:
Expand Down Expand Up @@ -142,7 +142,7 @@
)

#' @describeIn abnormal_by_baseline Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 145 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L145

"additional" is wordy or unneeded
#'
#' @return
#' * `count_abnormal_by_baseline()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -166,7 +166,7 @@
#' df2 <- data.frame(
#' ID = as.character(c(1, 2, 3, 4)),
#' RANGE = factor(c("NORMAL", "LOW", "HIGH", "HIGH")),
#' BLRANGE = factor(c("LOW", "HIGH", "HIGH", "NORMAL"))

Check notice on line 169 in R/abnormal_by_baseline.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_baseline.R#L169

""HIGH"," is repeated
#' )
#'
#' basic_table() %>%
Expand All @@ -183,6 +183,7 @@
count_abnormal_by_baseline <- function(lyt,
var,
abnormal,
nested = TRUE,
...,
table_names = abnormal,
.stats = NULL,
Expand All @@ -206,6 +207,7 @@
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 @@ -3,7 +3,7 @@
#' @description `r lifecycle::badge("stable")`
#'
#' Primary analysis variable `.var` indicates whether single, replicated or last marked laboratory
#' abnormality was observed (`factor`). Additional analysis variables are `id` (`character` or `factor`)

Check notice on line 6 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L6

"Additional" is wordy or unneeded
#' and `direction` (`factor`) indicating the direction of the abnormality. Denominator is number of
#' patients with at least one valid measurement during the analysis.
#' * For `Single, not last` and `Last or replicated`: Numerator is number of patients
Expand All @@ -17,7 +17,7 @@
#'
#' @note `Single, not last` and `Last or replicated` levels are mutually exclusive. If a patient has
#' abnormalities that meet both the `Single, not last` and `Last or replicated` criteria, then the
#' patient will be counted only under the `Last or replicated` category.

Check notice on line 20 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L20

"only" can weaken meaning
#'
#' @name abnormal_by_marked
NULL
Expand All @@ -35,11 +35,11 @@
#' USUBJID = as.character(c(rep(1, 5), rep(2, 5), rep(1, 5), rep(2, 5))),
#' ARMCD = factor(c(rep("ARM A", 5), rep("ARM B", 5), rep("ARM A", 5), rep("ARM B", 5))),
#' ANRIND = factor(c(
#' "NORMAL", "HIGH", "HIGH", "HIGH HIGH", "HIGH",

Check notice on line 38 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L38

""HIGH"," is repeated
#' "HIGH", "HIGH", "HIGH HIGH", "NORMAL", "HIGH HIGH", "NORMAL", "LOW", "LOW", "LOW LOW", "LOW",

Check notice on line 39 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L39

""HIGH"," is repeated

Check notice on line 39 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L39

""LOW"," is repeated
#' "LOW", "LOW", "LOW LOW", "NORMAL", "LOW LOW"

Check notice on line 40 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L40

""LOW"," is repeated
#' )),
#' ONTRTFL = rep(c("", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y"), 2),

Check notice on line 42 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L42

""Y"," is repeated

Check notice on line 42 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L42

""Y"," is repeated

Check notice on line 42 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L42

""Y"," is repeated

Check notice on line 42 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L42

""Y"," is repeated

Check notice on line 42 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L42

""Y"," is repeated

Check notice on line 42 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L42

""Y"," is repeated

Check notice on line 42 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L42

""Y"," is repeated
#' PARAMCD = factor(c(rep("CRP", 10), rep("ALT", 10))),
#' AVALCAT1 = factor(rep(c("", "", "", "SINGLE", "REPLICATED", "", "", "LAST", "", "SINGLE"), 2)),
#' stringsAsFactors = FALSE
Expand All @@ -55,7 +55,7 @@
#' levels = c("Low", "High")
#' ))
#'
#' # Select only post-baseline records.

Check notice on line 58 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L58

"only" can weaken meaning
#' df <- df %>% filter(ONTRTFL == "Y")
#' df_crp <- df %>%
#' filter(PARAMCD == "CRP") %>%
Expand Down Expand Up @@ -91,7 +91,7 @@
subj <- first_row$full_parent_df[[1]][[variables[["id"]]]]
subj_cur_col <- subj[first_row$cur_col_subset[[1]]]
# Some subjects may have a record for high and low directions but
# should be counted only once.

Check notice on line 94 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L94

"only" can weaken meaning
denom <- length(unique(subj_cur_col))

if (denom != 0) {
Expand All @@ -101,7 +101,7 @@
subjects_single <- unique(
df[df[[.var]] %in% category[["single"]], variables$id, drop = TRUE]
)
# Subjects who have both single and last/replicated abnormalities are counted in only the last/replicated group.

Check notice on line 104 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L104

"only" can weaken meaning
subjects_single <- setdiff(subjects_single, subjects_last_replicated)
n_single <- length(subjects_single)
n_last_replicated <- length(subjects_last_replicated)
Expand Down Expand Up @@ -136,7 +136,7 @@
)

#' @describeIn abnormal_by_marked Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 139 in R/abnormal_by_marked.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_marked.R#L139

"additional" is wordy or unneeded
#'
#' @return
#' * `count_abnormal_by_marked()` returns a layout object suitable for passing to further layouting functions,
Expand Down Expand Up @@ -196,6 +196,7 @@
#' @export
count_abnormal_by_marked <- function(lyt,
var,
nested = TRUE,
...,
.stats = NULL,
.formats = NULL,
Expand All @@ -216,6 +217,7 @@
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 @@ -2,7 +2,7 @@
#'
#' @description `r lifecycle::badge("stable")`
#'
#' Primary analysis variable `.var` indicates the toxicity grade (`factor`), and additional

Check notice on line 5 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L5

"additional" is wordy or unneeded
#' analysis variables are `id` (`character` or `factor`), `param` (`factor`) and `grade_dir` (`factor`).
#' The pre-processing steps are crucial when using this function.
#' For a certain direction (e.g. high or low) this function counts
Expand All @@ -15,12 +15,12 @@
#'
#' @details The pre-processing steps are crucial when using this function. From the standard lab grade variable
#' `ATOXGR`, derive the following two variables:
#' * A grade direction variable (e.g. `GRADE_DIR`) is required in order to obtain

Check notice on line 18 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L18

"in order to" is wordy or unneeded

Check notice on line 18 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L18

"obtain" is wordy or unneeded
#' the correct denominators when building the layout as it is used to define row splitting.

Check notice on line 19 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L19

"it is" is wordy or unneeded
#' * A toxicity grade variable (e.g. `GRADE_ANL`) where all negative values from
#' `ATOXGR` are replaced by their absolute values.
#'
#' @note Prior to tabulation, `df` must be filtered to include only post-baseline records with worst grade flags.

Check notice on line 23 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L23

"Prior to" is wordy or unneeded

Check notice on line 23 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L23

"only" can weaken meaning
#'
#' @name abnormal_by_worst_grade
NULL
Expand All @@ -36,7 +36,7 @@
#' library(forcats)
#' adlb <- tern_ex_adlb
#'
#' # Data is modified in order to have some parameters with grades only in one direction

Check notice on line 39 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L39

"in order to" is wordy or unneeded

Check notice on line 39 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L39

"only" can weaken meaning
#' # and simulate the real data.
#' adlb$ATOXGR[adlb$PARAMCD == "ALT" & adlb$ATOXGR %in% c("1", "2", "3", "4")] <- "-1"
#' adlb$ANRIND[adlb$PARAMCD == "ALT" & adlb$ANRIND == "HIGH"] <- "LOW"
Expand Down Expand Up @@ -104,7 +104,7 @@
subj <- first_row$full_parent_df[[1]][[variables[["id"]]]]
subj_cur_col <- subj[first_row$cur_col_subset[[1]]]
# Some subjects may have a record for high and low directions but
# should be counted only once.

Check notice on line 107 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L107

"only" can weaken meaning
denom <- length(unique(subj_cur_col))

for (lvl in x_lvls) {
Expand All @@ -114,7 +114,7 @@
df_lvl <- df[df[[.var]] != 0, ]
}
num <- length(unique(df_lvl[["USUBJID"]]))
fraction <- ifelse(denom == 0, 0, num / denom)

Check notice on line 117 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L117

"0," is repeated
result[[lvl]] <- formatters::with_label(c(count = num, fraction = fraction), lvl)
}

Expand All @@ -136,7 +136,7 @@
)

#' @describeIn abnormal_by_worst_grade Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 139 in R/abnormal_by_worst_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade.R#L139

"additional" is wordy or unneeded
#'
#' @return
#' * `count_abnormal_by_worst_grade()` returns a layout object suitable for passing to further layouting functions,
Expand Down Expand Up @@ -164,6 +164,7 @@
#' @export
count_abnormal_by_worst_grade <- function(lyt,
var,
nested = TRUE,
...,
.stats = NULL,
.formats = NULL,
Expand All @@ -181,6 +182,7 @@
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 @@ -21,15 +21,15 @@
#' @param worst_flag_low (named `vector`)\cr Worst low post-baseline lab grade flag variable
#' @param worst_flag_high (named `vector`)\cr Worst high post-baseline lab grade flag variable
#' @param direction_var (`string`)\cr Direction variable specifying the direction of the shift table of interest.
#' Only lab records flagged by `L`, `H` or `B` are included in the shift table.

Check notice on line 24 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L24

"Only" can weaken meaning
#' * `L`: low direction only

Check notice on line 25 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L25

"only" can weaken meaning
#' * `H`: high direction only

Check notice on line 26 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L26

"only" can weaken meaning
#' * `B`: both low and high directions
#'
#' @return `h_adlb_worsen()` returns the `adlb` `data.frame` containing only the

Check notice on line 29 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L29

"only" can weaken meaning
#' worst labs specified according to `worst_flag_low` or `worst_flag_high` for the
#' direction specified according to `direction_var`. For instance, for a lab that is
#' needed for the low direction only, only records flagged by `worst_flag_low` are

Check notice on line 32 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L32

"only" can weaken meaning

Check notice on line 32 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L32

"only" can weaken meaning
#' selected. For a lab that is needed for both low and high directions, the worst
#' low records are selected for the low direction, and the worst high record are selected
#' for the high direction.
Expand Down Expand Up @@ -207,7 +207,7 @@
# remove post-baseline missing
df <- df[df[[.var]] != "<Missing>", ]

# obtain directionality

Check notice on line 210 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L210

"obtain" is wordy or unneeded
direction <- unique(df[[direction_var]])

if (direction == "Low") {
Expand Down Expand Up @@ -254,7 +254,7 @@
con2 <- which(as.numeric(as.character(df_temp_nm[[.var]])) > as.numeric(as.character(df_temp_nm[[baseline_var]])))
}

# number of patients satisfy either conditions 1 or 2

Check notice on line 257 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L257

"satisfy" is wordy or unneeded
num <- length(unique(df_temp[union(con1, con2), id, drop = TRUE]))

list(fraction = c(by_grade, list("Any" = c(num = num, denom = denom))))
Expand All @@ -263,7 +263,7 @@
#' @describeIn abnormal_by_worst_grade_worsen Statistics function for patients whose worst post-baseline
#' lab grades are worse than their baseline grades.
#'
#' @param variables (named `list` of `string`)\cr list of additional analysis variables including:

Check notice on line 266 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L266

"additional" is wordy or unneeded
#' * `id` (`string`)\cr subject variable name.
#' * `baseline_var` (`string`)\cr name of the data column containing baseline toxicity variable.
#' * `direction_var` (`string`)\cr see `direction_var` for more details.
Expand Down Expand Up @@ -329,7 +329,7 @@
)

#' @describeIn abnormal_by_worst_grade_worsen Layout-creating function which can take statistics function
#' arguments and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 332 in R/abnormal_by_worst_grade_worsen.R

View workflow job for this annotation

GitHub Actions / grammar

R/abnormal_by_worst_grade_worsen.R#L332

"additional" is wordy or unneeded
#'
#' @return
#' * `count_abnormal_lab_worsen_by_baseline()` returns a layout object suitable for passing to further layouting
Expand All @@ -356,6 +356,7 @@
#' @export
count_abnormal_lab_worsen_by_baseline <- function(lyt, # nolint
var,
nested = TRUE,
...,
table_names = NULL,
.stats = NULL,
Expand All @@ -376,6 +377,7 @@
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
@@ -1,10 +1,10 @@
#' Standard Arguments
#'
#' The documentation to this function lists all the arguments in `tern`
#' that are used repeatedly to express an analysis.

Check notice on line 4 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L4

"repeatedly" can weaken meaning
#'
#' @param ... additional arguments for the lower level functions.

Check notice on line 6 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L6

"additional" is wordy or unneeded
#' @param .df_row (`data.frame`)\cr data frame across all of the columns for the given row split.

Check notice on line 7 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L7

"all of" is wordy or unneeded
#' @param .in_ref_col (`logical`)\cr `TRUE` when working with the reference level, `FALSE` otherwise.
#' @param .N_col (`count`)\cr row-wise N (row group count) for the group of observations being analyzed
#' (i.e. with no column-based subsetting) that is passed by `rtables`.
Expand All @@ -31,32 +31,32 @@
#' @param id (`string`)\cr subject variable name.
#' @param is_event (`logical`)\cr `TRUE` if event, `FALSE` if time to event is censored.
#' @param indent_mod `r lifecycle::badge("deprecated")` Please use the `.indent_mods` argument instead.
#' @param labelstr (`character`)\cr label of the level of the parent split currently being summarized

Check notice on line 34 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L34

"currently" can weaken meaning
#' (must be present as second argument in Content Row Functions). See [rtables::summarize_row_groups()]
#' for more information.
#' @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.

Check notice on line 38 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L38

"prior to" is wordy or unneeded
#' @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.

Check notice on line 44 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L44

"Only" can weaken meaning
#' @param prune_zero_rows (`flag`)\cr whether to prune all zero rows.
#' @param rsp (`logical`)\cr whether each subject is a responder or not.
#' @param show_labels (`string`)\cr label visibility: one of "default", "visible" and "hidden".
#' @param section_div (`string`)\cr string which should be repeated as a section divider after each group
#' defined by this split instruction, or `NA_character_` (the default) for no section divider.
#' @param table_names (`character`)\cr this can be customized in case that the same `vars` are analyzed multiple times,

Check notice on line 50 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L50

"multiple" is wordy or unneeded
#' to avoid warnings from `rtables`.
#' @param tte (`numeric`)\cr contains time-to-event duration values.
#' @param var_labels (`character`)\cr character for label.
#' @param variables (named `list` of `string`)\cr list of additional analysis variables.

Check notice on line 54 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L54

"additional" is wordy or unneeded
#' @param vars (`character`)\cr variable names for the primary analysis variable to be iterated over.
#' @param var (`string`)\cr single variable name for the primary analysis variable.
#' @param x (`numeric`)\cr vector of numbers we want to analyze.
#'
#' @details Although this function just returns `NULL` it has two uses, for

Check notice on line 59 in R/argument_convention.R

View workflow job for this annotation

GitHub Actions / grammar

R/argument_convention.R#L59

"just" can weaken meaning
#' the `tern` users it provides a documentation of arguments that are
#' commonly and consistently used in the framework. For the developer it adds a
#' single reference point to import the `roxygen` argument description with:
Expand Down
2 changes: 2 additions & 0 deletions R/count_cumulative.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
)

#' @describeIn count_cumulative Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 132 in R/count_cumulative.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_cumulative.R#L132

"additional" is wordy or unneeded
#'
#' @return
#' * `count_cumulative()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -151,6 +151,7 @@
vars,
var_labels = vars,
show_labels = "visible",
nested = TRUE,
...,
table_names = vars,
.stats = NULL,
Expand All @@ -172,6 +173,7 @@
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 @@ -80,7 +80,7 @@
)

#' @describeIn count_missed_doses Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 83 in R/count_missed_doses.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_missed_doses.R#L83

"additional" is wordy or unneeded
#'
#' @inheritParams s_count_cumulative
#'
Expand Down Expand Up @@ -112,6 +112,7 @@
vars,
var_labels = vars,
show_labels = "visible",
nested = TRUE,
...,
table_names = vars,
.stats = NULL,
Expand All @@ -133,6 +134,7 @@
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 @@ -4,13 +4,13 @@
#'
#' Functions for analyzing frequencies and fractions of occurrences for patients with occurrence
#' data. Primary analysis variables are the dictionary terms. All occurrences are counted for total
#' counts. Multiple occurrences within patient at the lowest term level displayed in the table are

Check notice on line 7 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L7

"Multiple" is wordy or unneeded
#' counted only once.

Check notice on line 8 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L8

"only" can weaken meaning
#'
#' @inheritParams argument_convention
#'
#' @note By default, occurrences which don't appear in a given row split are dropped from the table and
#' the occurrences in the table are sorted alphabetically per row split. Therefore, the corresponding layout

Check notice on line 13 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L13

"Therefore" is wordy or unneeded
#' needs to use `split_fun = drop_split_levels` in the `split_rows_by` calls. Use `drop = FALSE` if you would
#' like to show all occurrences.
#'
Expand All @@ -32,8 +32,8 @@
#'
#' @examples
#' df <- data.frame(
#' USUBJID = as.character(c(1, 1, 2, 4, 4, 4)),

Check notice on line 35 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L35

"4," is repeated
#' MHDECOD = c("MH1", "MH2", "MH1", "MH1", "MH1", "MH3")

Check notice on line 36 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L36

""MH1"," is repeated

Check notice on line 36 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L36

""MH1"," is repeated
#' )
#'
#' N_per_col <- 4L
Expand Down Expand Up @@ -112,7 +112,7 @@
#'
#' @examples
#' # We need to ungroup `count_fraction` first so that the `rtables` formatting
#' # function `format_count_fraction()` can be applied correctly.

Check notice on line 115 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L115

"correctly" can weaken meaning
#' afun <- make_afun(a_count_occurrences, .ungroup_stats = c("count", "count_fraction", "fraction"))
#' afun(
#' df,
Expand All @@ -129,7 +129,7 @@
)

#' @describeIn count_occurrences Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 132 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L132

"additional" is wordy or unneeded
#'
#' @return
#' * `count_occurrences()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -140,12 +140,12 @@
#' library(dplyr)
#' df <- data.frame(
#' USUBJID = as.character(c(
#' 1, 1, 2, 4, 4, 4,

Check notice on line 143 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L143

"1," is repeated

Check notice on line 143 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L143

"4," is repeated

Check notice on line 143 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L143

"4," is repeated
#' 6, 6, 6, 7, 7, 8

Check notice on line 144 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L144

"6," is repeated

Check notice on line 144 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L144

"6," is repeated

Check notice on line 144 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L144

"7," is repeated
#' )),
#' MHDECOD = c(
#' "MH1", "MH2", "MH1", "MH1", "MH1", "MH3",

Check notice on line 147 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L147

""MH1"," is repeated

Check notice on line 147 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L147

""MH1"," is repeated
#' "MH2", "MH2", "MH3", "MH1", "MH2", "MH4"

Check notice on line 148 in R/count_occurrences.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences.R#L148

""MH2"," is repeated
#' ),
#' ARM = rep(c("A", "B"), each = 6)
#' )
Expand All @@ -169,6 +169,7 @@
vars,
var_labels = vars,
show_labels = "hidden",
nested = TRUE,
...,
table_names = vars,
.stats = "count_fraction",
Expand All @@ -191,6 +192,7 @@
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 @@ -3,13 +3,13 @@
#' @description `r lifecycle::badge("stable")`
#'
#' Functions for analyzing frequencies and fractions of occurrences by grade for patients
#' with occurrence data. Multiple occurrences within one individual are counted once at the

Check notice on line 6 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L6

"Multiple" is wordy or unneeded
#' greatest intensity/highest grade level.
#'
#' @inheritParams argument_convention
#' @param grade_groups (named `list` of `character`)\cr containing groupings of grades.
#' @param remove_single (`logical`)\cr `TRUE` to not include the elements of one-element grade groups
#' in the the output list; in this case only the grade groups names will be included in the output.

Check notice on line 12 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L12

"the" is repeated

Check notice on line 12 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L12

"only" can weaken meaning
#'
#' @seealso Relevant helper function [h_append_grade_groups()].
#'
Expand Down Expand Up @@ -121,10 +121,10 @@
#' library(dplyr)
#' df <- data.frame(
#' USUBJID = as.character(c(1:6, 1)),
#' ARM = factor(c("A", "A", "A", "B", "B", "B", "A"), levels = c("A", "B")),

Check notice on line 124 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L124

""A"," is repeated

Check notice on line 124 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L124

""B"," is repeated

Check notice on line 124 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L124

""B"," is repeated
#' AETOXGR = factor(c(1, 2, 3, 4, 1, 2, 3), levels = c(1:5)),
#' AESEV = factor(
#' x = c("MILD", "MODERATE", "SEVERE", "MILD", "MILD", "MODERATE", "SEVERE"),

Check notice on line 127 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L127

""MILD"," is repeated
#' levels = c("MILD", "MODERATE", "SEVERE")
#' ),
#' stringsAsFactors = FALSE
Expand Down Expand Up @@ -179,7 +179,7 @@
grade <- formatters::with_label(factor(grade, levels = lvl_ord, ordered = TRUE), grade_lbl)
}

df_max <- stats::aggregate(grade ~ id, FUN = max, drop = FALSE)

Check notice on line 182 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L182

"aggregate" is wordy or unneeded
l_count <- as.list(table(df_max$grade))
}

Expand All @@ -202,7 +202,7 @@
#'
#' @examples
#' # We need to ungroup `count_fraction` first so that the `rtables` formatting
#' # function `format_count_fraction()` can be applied correctly.

Check notice on line 205 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L205

"correctly" can weaken meaning
#' afun <- make_afun(a_count_occurrences_by_grade, .ungroup_stats = "count_fraction")
#' afun(
#' df,
Expand All @@ -219,7 +219,7 @@
)

#' @describeIn count_occurrences_by_grade Layout-creating function which can take statistics function
#' arguments and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 222 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L222

"additional" is wordy or unneeded
#'
#' @param var_labels (`character`)\cr labels to show in the result table.
#'
Expand All @@ -239,7 +239,7 @@
#' ) %>%
#' build_table(df, alt_counts_df = df_adsl)
#'
#' # Define additional grade groupings.

Check notice on line 242 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L242

"additional" is wordy or unneeded
#' grade_groups <- list(
#' "-Any-" = c("1", "2", "3", "4", "5"),
#' "Grade 1-2" = c("1", "2"),
Expand All @@ -260,6 +260,7 @@
var,
var_labels = var,
show_labels = "default",
nested = TRUE,
...,
table_names = var,
.stats = NULL,
Expand All @@ -281,12 +282,13 @@
show_labels = show_labels,
afun = afun,
table_names = table_names,
nested = nested,
extra_args = list(...)
)
}

#' @describeIn count_occurrences_by_grade Layout-creating function which can take content function arguments
#' and additional format arguments. This function is a wrapper for [rtables::summarize_row_groups()].

Check notice on line 291 in R/count_occurrences_by_grade.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_occurrences_by_grade.R#L291

"additional" is wordy or unneeded
#'
#' @return
#' * `summarize_occurrences_by_grade()` returns a layout object suitable for passing to further layouting functions,
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 @@ -18,9 +18,9 @@
#' @param .var (`character`)\cr name of the column that contains the unique identifier.
#' @param filters (`character`)\cr a character vector specifying the column names and flag variables
#' to be used for counting the number of unique identifiers satisfying such conditions.
#' Multiple column names and flags are accepted in this format

Check notice on line 21 in R/count_patients_with_event.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_patients_with_event.R#L21

"Multiple" is wordy or unneeded
#' `c("column_name1" = "flag1", "column_name2" = "flag2")`.
#' Note that only equality is being accepted as condition.

Check notice on line 23 in R/count_patients_with_event.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_patients_with_event.R#L23

"only" can weaken meaning
#'
#' @return
#' * `s_count_patients_with_event()` returns the count and fraction of unique identifiers with the defined event.
Expand Down Expand Up @@ -101,7 +101,7 @@
)

#' @describeIn count_patients_with_event Layout-creating function which can take statistics function
#' arguments and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 104 in R/count_patients_with_event.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_patients_with_event.R#L104

"additional" is wordy or unneeded
#'
#' @return
#' * `count_patients_with_event()` returns a layout object suitable for passing to further layouting functions,
Expand Down Expand Up @@ -144,6 +144,7 @@
#' @export
count_patients_with_event <- function(lyt,
vars,
nested = TRUE,
...,
table_names = vars,
.stats = "count_fraction",
Expand All @@ -162,6 +163,7 @@
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 @@ -21,7 +21,7 @@
#' @param flag_labels (`character`)\cr vector of labels to use for flag variables.
#'
#' @note If `flag_labels` is not specified, variables labels will be extracted from `df`. If variables are not
#' labeled, variable names will be used instead. Alternatively, a named `vector` can be supplied to

Check notice on line 24 in R/count_patients_with_flags.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_patients_with_flags.R#L24

"Alternatively" can weaken meaning and is wordy or unneeded
#' `flag_variables` such that within each name-value pair the name corresponds to the variable name and the value is
#' the label to use for this variable.
#'
Expand Down Expand Up @@ -109,7 +109,7 @@
#'
#' @examples
#' # We need to ungroup `count_fraction` first so that the `rtables` formatting
#' # function `format_count_fraction()` can be applied correctly.

Check notice on line 112 in R/count_patients_with_flags.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_patients_with_flags.R#L112

"correctly" can weaken meaning
#'
#' # `a_count_patients_with_flags()`
#'
Expand All @@ -132,7 +132,7 @@
)

#' @describeIn count_patients_with_flags Layout-creating function which can take statistics function
#' arguments and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 135 in R/count_patients_with_flags.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_patients_with_flags.R#L135

"additional" is wordy or unneeded
#'
#' @return
#' * `count_patients_with_flags()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -157,6 +157,7 @@
var,
var_labels = var,
show_labels = "hidden",
nested = TRUE,
...,
table_names = paste0("tbl_flags_", var),
.stats = "count_fraction",
Expand All @@ -177,6 +178,7 @@
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 @@ -105,7 +105,7 @@
)

#' @describeIn count_values_funs Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 108 in R/count_values.R

View workflow job for this annotation

GitHub Actions / grammar

R/count_values.R#L108

"additional" is wordy or unneeded
#'
#' @return
#' * `count_values()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -122,6 +122,7 @@
count_values <- function(lyt,
vars,
values,
nested = TRUE,
...,
table_names = vars,
.stats = "count_fraction",
Expand All @@ -139,6 +140,7 @@
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 @@ -3,7 +3,7 @@
#' @description `r lifecycle::badge("stable")`
#'
#' Estimate the proportion along with confidence interval of a proportion
#' regarding the level of a factor.

Check notice on line 6 in R/estimate_multinomial_rsp.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_multinomial_rsp.R#L6

"regarding" is wordy or unneeded
#'
#' @inheritParams argument_convention
#'
Expand Down Expand Up @@ -108,7 +108,7 @@
)

#' @describeIn estimate_multinomial_rsp Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()] and

Check notice on line 111 in R/estimate_multinomial_rsp.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_multinomial_rsp.R#L111

"additional" is wordy or unneeded
#' [rtables::summarize_row_groups()].
#'
#' @return
Expand All @@ -123,7 +123,7 @@
#' dta_test <- data.frame(
#' USUBJID = paste0("S", 1:12),
#' ARM = factor(rep(LETTERS[1:3], each = 4)),
#' AVAL = c(A = c(1, 1, 1, 1), B = c(0, 0, 1, 1), C = c(0, 0, 0, 0))

Check notice on line 126 in R/estimate_multinomial_rsp.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_multinomial_rsp.R#L126

"1," is repeated

Check notice on line 126 in R/estimate_multinomial_rsp.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_multinomial_rsp.R#L126

"0," is repeated
#' ) %>% mutate(
#' AVALC = factor(AVAL,
#' levels = c(0, 1),
Expand All @@ -146,6 +146,7 @@
#' @export
estimate_multinomial_response <- function(lyt,
var,
nested = TRUE,
...,
show_labels = "hidden",
table_names = var,
Expand All @@ -169,6 +170,7 @@
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 @@ -15,11 +15,11 @@
#' proportion along with its confidence interval.
#'
#' @inheritParams prop_strat_wilson
#' @param df (`logical` or `data.frame`)\cr if only a logical vector is used,

Check notice on line 18 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L18

"only" can weaken meaning
#' it indicates whether each subject is a responder or not. `TRUE` represents
#' a successful outcome. If a `data.frame` is provided, also the `strata` variable
#' names must be provided in `variables` as a list element with the strata strings.
#' In the case of `data.frame`, the logical vector of responses must be indicated as a

Check notice on line 22 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L22

"In the case of" is wordy or unneeded
#' variable name in `.var`.
#' @param method (`string`)\cr the method used to construct the confidence interval
#' for proportion of successful outcomes; one of `waldcc`, `wald`, `clopper-pearson`,
Expand All @@ -31,8 +31,8 @@
#' given variable.
#'
#' @examples
#' # Case with only logical vector.

Check notice on line 34 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L34

"only" can weaken meaning
#' rsp_v <- c(1, 0, 1, 0, 1, 1, 0, 0)

Check notice on line 35 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L35

"1," is repeated
#' s_proportion(rsp_v)
#'
#' # Example for Stratified Wilson CI
Expand Down Expand Up @@ -138,7 +138,7 @@
)

#' @describeIn estimate_proportions Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 141 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L141

"additional" is wordy or unneeded
#'
#' @param ... other arguments are ultimately conveyed to [s_proportion()].
#'
Expand All @@ -151,7 +151,7 @@
#' dta_test <- data.frame(
#' USUBJID = paste0("S", 1:12),
#' ARM = rep(LETTERS[1:3], each = 4),
#' AVAL = c(A = c(1, 1, 1, 1), B = c(0, 0, 1, 1), C = c(0, 0, 0, 0))

Check notice on line 154 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L154

"1," is repeated

Check notice on line 154 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L154

"0," is repeated
#' )
#'
#' basic_table() %>%
Expand All @@ -162,6 +162,7 @@
#' @export
estimate_proportion <- function(lyt,
vars,
nested = TRUE,
...,
show_labels = "hidden",
table_names = vars,
Expand All @@ -180,6 +181,7 @@
lyt,
vars,
afun = afun,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand Down Expand Up @@ -208,8 +210,8 @@
#'
#' @examples
#' rsp <- c(
#' TRUE, TRUE, TRUE, TRUE, TRUE,

Check notice on line 213 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L213

"TRUE," is repeated

Check notice on line 213 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L213

"TRUE," is repeated

Check notice on line 213 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L213

"TRUE," is repeated

Check notice on line 213 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L213

"TRUE," is repeated
#' FALSE, FALSE, FALSE, FALSE, FALSE

Check notice on line 214 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L214

"FALSE," is repeated

Check notice on line 214 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L214

"FALSE," is repeated

Check notice on line 214 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L214

"FALSE," is repeated
#' )
#' prop_wilson(rsp, conf_level = 0.9)
#'
Expand All @@ -232,7 +234,7 @@
#' @param weights (`numeric` or `NULL`)\cr weights for each level of the strata. If `NULL`, they are
#' estimated using the iterative algorithm proposed in \insertCite{Yan2010-jt;textual}{tern} that
#' minimizes the weighted squared length of the confidence interval.
#' @param max_iterations (`count`)\cr maximum number of iterations for the iterative procedure used

Check notice on line 237 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L237

"maximum" is wordy or unneeded
#' to find estimates of optimal weights.
#' @param correct (`flag`)\cr include the continuity correction. For further information, see for example
#' [stats::prop.test()].
Expand Down Expand Up @@ -279,7 +281,7 @@
tbl <- table(rsp, strata)
n_strata <- length(unique(strata))

# Checking the weights and maximum number of iterations.

Check notice on line 284 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L284

"maximum" is wordy or unneeded
do_iter <- FALSE
if (is.null(weights)) {
weights <- rep(1 / n_strata, n_strata) # Initialization for iterative procedure
Expand Down Expand Up @@ -428,7 +430,7 @@
alpha <- 1 - conf_level
l_ci <- ifelse(
x_sum == 0,
0,

Check notice on line 433 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L433

"0," is repeated
stats::qbeta(alpha / 2, x_sum + 0.5, n - x_sum + 0.5)
)

Expand Down Expand Up @@ -481,7 +483,7 @@
#' @description `r lifecycle::badge("stable")`
#'
#' This function wraps the estimation of stratified percentiles when we assume
#' the approximation for large numbers. This is necessary only in the case

Check notice on line 486 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L486

"only" can weaken meaning
#' proportions for each strata are unequal.
#'
#' @inheritParams argument_convention
Expand Down Expand Up @@ -515,7 +517,7 @@
#' @description `r lifecycle::badge("stable")`
#'
#' This function wraps the iteration procedure that allows you to estimate
#' the weights for each proportional strata. This assumes to minimize the

Check notice on line 520 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L520

"minimize" is wordy or unneeded
#' weighted squared length of the confidence interval.
#'
#' @inheritParams prop_strat_wilson
Expand All @@ -524,7 +526,7 @@
#' @param initial_weights (`numeric`)\cr initial weights used to calculate `strata_qnorm`. This can
#' be optimized in the future if we need to estimate better initial weights.
#' @param n_per_strata (`numeric`)\cr number of elements in each strata.
#' @param max_iterations (`count`)\cr maximum number of iterations to be tried. Convergence is always checked.

Check notice on line 529 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L529

"maximum" is wordy or unneeded
#' @param tol (`number`)\cr tolerance threshold for convergence.
#'
#' @return A `list` of 3 elements: `n_it`, `weights`, and `diff_v`.
Expand All @@ -535,7 +537,7 @@
#' vs <- c(0.011, 0.013, 0.012, 0.014, 0.017, 0.018)
#' sq <- 0.674
#' ws <- rep(1 / length(vs), length(vs))
#' ns <- c(22, 18, 17, 17, 14, 12)

Check notice on line 540 in R/estimate_proportion.R

View workflow job for this annotation

GitHub Actions / grammar

R/estimate_proportion.R#L540

"17," is repeated
#'
#' update_weights_strat_wilson(vs, sq, ws, ns, 100, 0.95, 0.001)
#'
Expand Down
2 changes: 2 additions & 0 deletions R/incidence_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
#'
#' df <- data.frame(
#' USUBJID = as.character(seq(6)),
#' CNSR = c(0, 1, 1, 0, 0, 0),

Check notice on line 41 in R/incidence_rate.R

View workflow job for this annotation

GitHub Actions / grammar

R/incidence_rate.R#L41

"1," is repeated

Check notice on line 41 in R/incidence_rate.R

View workflow job for this annotation

GitHub Actions / grammar

R/incidence_rate.R#L41

"0," is repeated
#' AVAL = c(10.1, 20.4, 15.3, 20.8, 18.7, 23.4),
#' ARM = factor(c("A", "A", "A", "B", "B", "B"))

Check notice on line 43 in R/incidence_rate.R

View workflow job for this annotation

GitHub Actions / grammar

R/incidence_rate.R#L43

""A"," is repeated

Check notice on line 43 in R/incidence_rate.R

View workflow job for this annotation

GitHub Actions / grammar

R/incidence_rate.R#L43

""B"," is repeated
#' ) %>%
#' mutate(is_event = CNSR == 0) %>%
#' mutate(n_events = as.integer(is_event))
Expand Down Expand Up @@ -111,7 +111,7 @@
)

#' @describeIn incidence_rate Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 114 in R/incidence_rate.R

View workflow job for this annotation

GitHub Actions / grammar

R/incidence_rate.R#L114

"additional" is wordy or unneeded
#'
#' @return
#' * `estimate_incidence_rate()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -135,6 +135,7 @@
#' @export
estimate_incidence_rate <- function(lyt,
vars,
nested = TRUE,
...,
show_labels = "hidden",
table_names = vars,
Expand All @@ -156,6 +157,7 @@
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 @@ -2,7 +2,7 @@
#'
#' @description `r lifecycle::badge("stable")`
#'
#' Compares bivariate responses between two groups in terms of odds ratios

Check notice on line 5 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L5

"in terms of" is wordy or unneeded
#' along with a confidence interval.
#'
#' @inheritParams argument_convention
Expand All @@ -12,9 +12,9 @@
#' The Wald confidence interval with the specified confidence level is
#' calculated.
#'
#' @note For stratified analyses, there is currently no implementation for conditional

Check notice on line 15 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L15

"currently" can weaken meaning
#' likelihood confidence intervals, therefore the likelihood confidence interval is not

Check notice on line 16 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L16

"therefore" is wordy or unneeded
#' yet available as an option. Besides, when `rsp` contains only responders or non-responders,

Check notice on line 17 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L17

"only" can weaken meaning
#' then the result values will be `NA`, because no odds ratio estimation is possible.
#'
#' @seealso Relevant helper function [h_odds_ratio()].
Expand Down Expand Up @@ -164,7 +164,7 @@
)

#' @describeIn odds_ratio Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 167 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L167

"additional" is wordy or unneeded
#'
#' @param ... arguments passed to `s_odds_ratio()`.
#'
Expand All @@ -188,6 +188,7 @@
#' @export
estimate_odds_ratio <- function(lyt,
vars,
nested = TRUE,
...,
show_labels = "hidden",
table_names = vars,
Expand All @@ -207,6 +208,7 @@
lyt,
vars,
afun = afun,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand All @@ -231,14 +233,14 @@
NULL

#' @describeIn h_odds_ratio Estimates the odds ratio based on [stats::glm()]. Note that there must be
#' exactly 2 groups in `data` as specified by the `grp` variable.

Check notice on line 236 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L236

"exactly" can weaken meaning
#'
#' @examples
#' # Data with 2 groups.
#' data <- data.frame(
#' rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1)),

Check notice on line 241 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L241

"0," is repeated
#' grp = letters[c(1, 1, 1, 2, 2, 2, 1, 2)],

Check notice on line 242 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L242

"1," is repeated

Check notice on line 242 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L242

"2," is repeated

Check notice on line 242 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L242

"2," is repeated
#' strata = letters[c(1, 2, 1, 2, 2, 2, 1, 2)],

Check notice on line 243 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L243

"2," is repeated

Check notice on line 243 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L243

"2," is repeated
#' stringsAsFactors = TRUE
#' )
#'
Expand Down Expand Up @@ -279,9 +281,9 @@
#' @examples
#' # Data with 3 groups.
#' data <- data.frame(
#' rsp = as.logical(c(1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)),

Check notice on line 284 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L284

"0," is repeated

Check notice on line 284 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L284

"1," is repeated

Check notice on line 284 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L284

"0," is repeated

Check notice on line 284 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L284

"1," is repeated

Check notice on line 284 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L284

"0," is repeated

Check notice on line 284 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L284

"1," is repeated
#' grp = letters[c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3)],

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"2," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"3," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"3," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"3," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"1," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"1," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"2," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"2," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"3," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"3," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"1," is repeated

Check notice on line 285 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L285

"2," is repeated
#' strata = LETTERS[c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)],

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"1," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated

Check notice on line 286 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L286

"2," is repeated
#' stringsAsFactors = TRUE
#' )
#'
Expand All @@ -299,7 +301,7 @@
data$grp <- as_factor_keep_attributes(data$grp)
data$strata <- as_factor_keep_attributes(data$strata)

# Deviation from convention: `survival::strata` must be simply `strata`.

Check notice on line 304 in R/odds_ratio.R

View workflow job for this annotation

GitHub Actions / grammar

R/odds_ratio.R#L304

"simply" can weaken meaning
formula <- stats::as.formula("rsp ~ grp + strata(strata)")
model_fit <- clogit_with_tryCatch(formula = formula, data = data)

Expand Down
2 changes: 2 additions & 0 deletions R/prop_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
NULL

#' @describeIn prop_diff Statistics function estimating the difference
#' in terms of responder proportion.

Check notice on line 13 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L13

"in terms of" is wordy or unneeded
#'
#' @inheritParams prop_diff_strat_nc
#' @param method (`string`)\cr the method used for the confidence interval estimation.
Expand Down Expand Up @@ -168,7 +168,7 @@
)

#' @describeIn prop_diff Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 171 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L171

"additional" is wordy or unneeded
#'
#' @param ... arguments passed to `s_proportion_diff()`.
#'
Expand All @@ -191,6 +191,7 @@
#' @export
estimate_proportion_diff <- function(lyt,
vars,
nested = TRUE,
...,
var_labels = vars,
show_labels = "hidden",
Expand All @@ -212,6 +213,7 @@
vars,
afun = afun,
var_labels = var_labels,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand Down Expand Up @@ -307,7 +309,7 @@

#' @describeIn h_prop_diff The Wald interval follows the usual textbook
#' definition for a single proportion confidence interval using the normal
#' approximation. It is possible to include a continuity correction for Wald's

Check notice on line 312 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L312

"It is" is wordy or unneeded
#' interval.
#'
#' @param correct (`logical`)\cr whether to include the continuity correction. For further
Expand Down Expand Up @@ -359,7 +361,7 @@
#' @examples
#' # Anderson-Hauck confidence interval
#' ## "Mid" case: 3/4 respond in group A, 1/2 respond in group B.
#' rsp <- c(TRUE, FALSE, FALSE, TRUE, TRUE, TRUE)

Check notice on line 364 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L364

"FALSE," is repeated

Check notice on line 364 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L364

"TRUE," is repeated
#' grp <- factor(c("A", "B", "A", "B", "A", "A"), levels = c("B", "A"))
#' prop_diff_ha(rsp = rsp, grp = grp, conf_level = 0.90)
#'
Expand Down Expand Up @@ -389,7 +391,7 @@
)
}

#' @describeIn h_prop_diff `Newcombe` confidence interval. It is based on

Check notice on line 394 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L394

"It is" is wordy or unneeded
#' the Wilson score confidence interval for a single binomial proportion.
#'
#' @examples
Expand Down Expand Up @@ -524,7 +526,7 @@

#' @describeIn h_prop_diff Calculates the stratified `Newcombe` confidence interval and difference in response
#' rates between the experimental treatment group and the control treatment group, adjusted for stratification
#' factors. This implementation follows closely the one proposed by \insertCite{Yan2010-jt;textual}{tern}.

Check notice on line 529 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L529

"closely" can weaken meaning
#' Weights can be estimated from the heuristic proposed in [prop_strat_wilson()] or from `CMH`-derived weights
#' (see [prop_diff_cmh()]).
#'
Expand Down Expand Up @@ -582,7 +584,7 @@
strata_by_grp <- split(strata, f = grp)

# Finding the weights
weights <- if (identical(weights_method, "cmh")) {

Check notice on line 587 in R/prop_diff.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff.R#L587

"weights" is repeated
prop_diff_cmh(rsp = rsp, grp = grp, strata = strata)$weights
} else if (identical(weights_method, "wilson_h")) {
prop_strat_wilson(rsp, strata, conf_level = conf_level, correct = correct)$weights
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 @@ -2,7 +2,7 @@
#'
#' @description `r lifecycle::badge("stable")`
#'
#' Various tests were implemented to test the difference between two proportions.

Check notice on line 5 in R/prop_diff_test.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff_test.R#L5

"Various" is a weasel word
#'
#' @inheritParams argument_convention
#' @param tbl (`matrix`)\cr matrix with two groups in rows and the binary response (`TRUE`/`FALSE`) in columns.
Expand Down Expand Up @@ -107,7 +107,7 @@
)

#' @describeIn prop_diff_test Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 110 in R/prop_diff_test.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff_test.R#L110

"additional" is wordy or unneeded
#'
#' @param ... other arguments are passed to [s_test_proportion_diff()].
#'
Expand Down Expand Up @@ -136,6 +136,7 @@
#' @export
test_proportion_diff <- function(lyt,
vars,
nested = TRUE,
...,
var_labels = vars,
show_labels = "hidden",
Expand All @@ -156,6 +157,7 @@
vars,
afun = afun,
var_labels = var_labels,
nested = nested,
extra_args = list(...),
show_labels = show_labels,
table_names = table_names
Expand All @@ -164,7 +166,7 @@

#' Helper Functions to Test Proportion Differences
#'
#' Helper functions to implement various tests on the difference between two proportions.

Check notice on line 169 in R/prop_diff_test.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff_test.R#L169

"implement" is wordy or unneeded

Check notice on line 169 in R/prop_diff_test.R

View workflow job for this annotation

GitHub Actions / grammar

R/prop_diff_test.R#L169

"various" is a weasel word
#'
#' @param tbl (`matrix`)\cr matrix with two groups in rows and the binary response (`TRUE`/`FALSE`) in columns.
#'
Expand Down
2 changes: 2 additions & 0 deletions R/summarize_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#'
#' @description `r lifecycle::badge("stable")`
#'
#' Summarize results of `ANCOVA`. This can be used to analyze multiple endpoints and/or

Check notice on line 5 in R/summarize_ancova.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_ancova.R#L5

"multiple" is wordy or unneeded
#' multiple timepoints within the same response variable `.var`.

Check notice on line 6 in R/summarize_ancova.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_ancova.R#L6

"multiple" is wordy or unneeded
#'
#' @inheritParams argument_convention
#'
Expand All @@ -16,8 +16,8 @@
#'
#' @inheritParams argument_convention
#' @param .df_row (`data.frame`)\cr data set that includes all the variables that are called in `.var` and `variables`.
#' @param variables (named `list` of `strings`)\cr list of additional analysis variables, with expected elements:

Check notice on line 19 in R/summarize_ancova.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_ancova.R#L19

"additional" is wordy or unneeded
#' * `arm` (`string`)\cr group variable, for which the covariate adjusted means of multiple groups will be

Check notice on line 20 in R/summarize_ancova.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_ancova.R#L20

"multiple" is wordy or unneeded
#' summarized. Specifically, the first level of `arm` variable is taken as the reference group.
#' * `covariates` (`character`)\cr a vector that can contain single variable names (such as `"X1"`), and/or
#' interaction terms indicated by `"X1 * X2"`.
Expand Down Expand Up @@ -94,7 +94,7 @@
#' If working with the reference group, this will be empty.
#' * `lsmean_diff_ci`: Confidence level for difference in estimated marginal means in comparison
#' to the reference group.
#' * `pval`: p-value (not adjusted for multiple comparisons).

Check notice on line 97 in R/summarize_ancova.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_ancova.R#L97

"multiple" is wordy or unneeded
#'
#' @examples
#' library(dplyr)
Expand Down Expand Up @@ -127,7 +127,7 @@

sum_level <- as.character(unique(df[[arm]]))

# Ensure that there is only one element in sum_level.

Check notice on line 130 in R/summarize_ancova.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_ancova.R#L130

"only" can weaken meaning
checkmate::assert_scalar(sum_level)

sum_fit_level <- sum_fit[sum_fit[[arm]] == sum_level, ]
Expand Down Expand Up @@ -214,7 +214,7 @@
)

#' @describeIn summarize_ancova Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 217 in R/summarize_ancova.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_ancova.R#L217

"additional" is wordy or unneeded
#'
#' @return
#' * `summarize_ancova()` returns a layout object suitable for passing to further layouting functions,
Expand Down Expand Up @@ -244,6 +244,7 @@
summarize_ancova <- function(lyt,
vars,
var_labels,
nested = TRUE,
...,
show_labels = "visible",
table_names = vars,
Expand All @@ -270,6 +271,7 @@
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 @@ -3,7 +3,7 @@
#' @description `r lifecycle::badge("stable")`
#'
#' The primary analysis variable `.var` indicates the numerical change from baseline results,
#' and additional required secondary analysis variables are `value` and `baseline_flag`.

Check notice on line 6 in R/summarize_change.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_change.R#L6

"additional" is wordy or unneeded
#' Depending on the baseline flag, either the absolute baseline values (at baseline)
#' or the change from baseline values (post-baseline) are then summarized.
#'
Expand Down Expand Up @@ -78,14 +78,14 @@
)

#' @describeIn summarize_change Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 81 in R/summarize_change.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_change.R#L81

"additional" is wordy or unneeded
#'
#' @return
#' * `summarize_change()` returns a layout object suitable for passing to further layouting functions,
#' or to [rtables::build_table()]. Adding this function to an `rtable` layout will add formatted rows containing
#' the statistics from `s_change_from_baseline()` to the table layout.
#'
#' @note To be used after a split on visits in the layout, such that each data subset only contains

Check notice on line 88 in R/summarize_change.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_change.R#L88

"only" can weaken meaning
#' either baseline or post-baseline data.
#'
#' @examples
Expand Down Expand Up @@ -120,6 +120,7 @@
#' @export
summarize_change <- function(lyt,
vars,
nested = TRUE,
...,
table_names = vars,
.stats = c("n", "mean_sd", "median", "range"),
Expand All @@ -138,6 +139,7 @@
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 @@ -14,7 +14,7 @@
#'
#' @description `r lifecycle::badge("experimental")`
#'
#' Helper functions that can be used to return the results of various Poisson models.

Check notice on line 17 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L17

"various" is a weasel word
#'
#' @inheritParams argument_convention
#'
Expand All @@ -27,9 +27,9 @@
#'
#' @param .df_row (`data.frame`)\cr data set that includes all the variables that are called
#' in `.var` and `variables`.
#' @param variables (named `list` of `strings`)\cr list of additional analysis variables, with

Check notice on line 30 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L30

"additional" is wordy or unneeded
#' expected elements:
#' * `arm` (`string`)\cr group variable, for which the covariate adjusted means of multiple

Check notice on line 32 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L32

"multiple" is wordy or unneeded
#' groups will be summarized. Specifically, the first level of `arm` variable is taken as the
#' reference group.
#' * `covariates` (`character`)\cr a vector that can contain single variable names (such as
Expand Down Expand Up @@ -133,9 +133,9 @@
#'
#' @param .df_row (`data.frame`)\cr data set that includes all the variables that are called
#' in `.var` and `variables`.
#' @param variables (named `list` of `strings`)\cr list of additional analysis variables, with

Check notice on line 136 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L136

"additional" is wordy or unneeded
#' expected elements:
#' * `arm` (`string`)\cr group variable, for which the covariate adjusted means of multiple

Check notice on line 138 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L138

"multiple" is wordy or unneeded
#' groups will be summarized. Specifically, the first level of `arm` variable is taken as the
#' reference group.
#' * `covariates` (`character`)\cr a vector that can contain single variable names (such as
Expand All @@ -156,7 +156,7 @@
distribution,
weights) {
if (distribution == "negbin") {
stop("negative binomial distribution is not currently available.")

Check notice on line 159 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L159

"currently" can weaken meaning
}
switch(distribution,
poisson = h_glm_poisson(.var, .df_row, variables, weights),
Expand All @@ -170,7 +170,7 @@
#' @param .df_row (`data.frame`)\cr data set that includes all the variables that are called in `.var` and `variables`.
#' @param conf_level (`numeric`)\cr value used to derive the confidence interval for the rate.
#' @param obj (`glm.fit`)\cr fitted model object used to derive the mean rate estimates in each treatment arm.
#' @param `arm` (`string`)\cr group variable, for which the covariate adjusted means of multiple groups will be

Check notice on line 173 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L173

"multiple" is wordy or unneeded
#' summarized. Specifically, the first level of `arm` variable is taken as the reference group.
#'
#' @return
Expand Down Expand Up @@ -246,7 +246,7 @@
y <- df[[.var]]
smry_level <- as.character(unique(df[[arm]]))

# ensure there is only 1 value

Check notice on line 249 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L249

"only" can weaken meaning
checkmate::assert_scalar(smry_level)

results <- h_glm_count(
Expand Down Expand Up @@ -347,7 +347,7 @@
)

#' @describeIn summarize_glm_count Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 350 in R/summarize_glm_count.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_glm_count.R#L350

"additional" is wordy or unneeded
#'
#' @return
#' * `summarize_glm_count()` returns a layout object suitable for passing to further layouting functions,
Expand Down Expand Up @@ -400,6 +400,7 @@
summarize_glm_count <- function(lyt,
vars,
var_labels,
nested = TRUE,
...,
show_labels = "visible",
table_names = vars,
Expand All @@ -422,6 +423,7 @@
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 @@ -15,7 +15,7 @@
NULL

#' @describeIn summarize_num_patients Statistics function which counts the number of
#' unique patients, the corresponding percentage taken with respect to the

Check notice on line 18 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L18

"with respect to" is wordy or unneeded
#' total number of patients, and the number of non-unique patients.
#'
#' @return
Expand All @@ -26,12 +26,12 @@
#'
#' @examples
#' # Use the statistics function to count number of unique and nonunique patients.
#' s_num_patients(x = as.character(c(1, 1, 1, 2, 4, NA)), labelstr = "", .N_col = 6L)

Check notice on line 29 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L29

"1," is repeated
#' s_num_patients(
#' x = as.character(c(1, 1, 1, 2, 4, NA)),

Check notice on line 31 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L31

"1," is repeated
#' labelstr = "",
#' .N_col = 6L,
#' count_by = as.character(c(1, 1, 2, 1, 1, 1))

Check notice on line 34 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L34

"1," is repeated
#' )
#'
#' @export
Expand All @@ -52,7 +52,7 @@
}

out <- list(
unique = formatters::with_label(c(count1, ifelse(count1 == 0 && .N_col == 0, 0, count1 / .N_col)), labelstr),

Check notice on line 55 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L55

"0," is repeated
nonunique = formatters::with_label(count2, labelstr),
unique_count = formatters::with_label(count1, ifelse(unique_count_suffix, paste(labelstr, "(n)"), labelstr))
)
Expand All @@ -61,7 +61,7 @@
}

#' @describeIn summarize_num_patients Statistics function which counts the number of unique patients
#' in a column (variable), the corresponding percentage taken with respect to the total number of

Check notice on line 64 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L64

"with respect to" is wordy or unneeded
#' patients, and the number of non-unique patients in the column.
#'
#' @param required (`character` or `NULL`)\cr optional name of a variable that is required to be non-missing.
Expand Down Expand Up @@ -127,7 +127,7 @@
)

#' @describeIn summarize_num_patients Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::summarize_row_groups()].

Check notice on line 130 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L130

"additional" is wordy or unneeded
#'
#' @return
#' * `summarize_num_patients()` returns a layout object suitable for passing to further layouting functions,
Expand Down Expand Up @@ -171,7 +171,7 @@
}

#' @describeIn summarize_num_patients Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 174 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L174

"additional" is wordy or unneeded
#'
#' @return
#' * `analyze_num_patients()` returns a layout object suitable for passing to further layouting functions,
Expand All @@ -182,16 +182,16 @@
#' work like [rtables::analyze()], while functions that starts with `summarize*`
#' are based upon [rtables::summarize_row_groups()]. The latter provides a
#' value for each dividing split in the row and column space, but, being it
#' bound to the fundamental splits, it is repeated by design in every page

Check notice on line 185 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L185

"it is" is wordy or unneeded
#' when pagination is involved.
#'
#' @note As opposed to [summarize_num_patients()], this function does not repeat the produced rows.
#'
#' @examples
#' df_tmp <- data.frame(
#' USUBJID = as.character(c(1, 2, 1, 4, NA, 6, 6, 8, 9)),

Check notice on line 192 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L192

"6," is repeated
#' ARM = c("A", "A", "A", "A", "A", "B", "B", "B", "B"),

Check notice on line 193 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L193

""A"," is repeated

Check notice on line 193 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L193

""A"," is repeated

Check notice on line 193 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L193

""A"," is repeated

Check notice on line 193 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L193

""B"," is repeated

Check notice on line 193 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L193

""B"," is repeated
#' AGE = c(10, 15, 10, 17, 8, 11, 11, 19, 17)

Check notice on line 194 in R/summarize_num_patients.R

View workflow job for this annotation

GitHub Actions / grammar

R/summarize_num_patients.R#L194

"11," is repeated
#' )
#' tbl <- basic_table() %>%
#' split_cols_by("ARM") %>%
Expand All @@ -203,6 +203,7 @@
#' @export
analyze_num_patients <- function(lyt,
vars,
nested = TRUE,
.stats = NULL,
.formats = NULL,
.labels = c(
Expand Down Expand Up @@ -232,6 +233,7 @@
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 @@ -132,7 +132,7 @@
)

#' @describeIn survival_coxph_pairwise Layout-creating function which can take statistics function arguments
#' and additional format arguments. This function is a wrapper for [rtables::analyze()].

Check notice on line 135 in R/survival_coxph_pairwise.R

View workflow job for this annotation

GitHub Actions / grammar

R/survival_coxph_pairwise.R#L135

"additional" is wordy or unneeded
#'
#' @return
#' * `coxph_pairwise()` returns a layout object suitable for passing to further layouting functions,
Expand Down Expand Up @@ -165,6 +165,7 @@
#' @export
coxph_pairwise <- function(lyt,
vars,
nested = TRUE,
...,
var_labels = "CoxPH",
show_labels = "visible",
Expand All @@ -187,6 +188,7 @@
show_labels = show_labels,
table_names = table_names,
afun = afun,
nested = nested,
extra_args = list(...)
)
}
Loading
Loading