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

Tidy Roxygen documentation (newlines & bullet lists) #838

Merged
merged 2 commits into from
Feb 27, 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Imports:
rlang,
scales,
stats,
survival (>= 3.1-11),
survival (>= 3.2-13),
tibble,
tidyr,
utils
Expand Down
11 changes: 5 additions & 6 deletions R/abnormal.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#'
#' @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
#' factor). For each direction specified in `abnormal` (e.g. high or low) count patients in the
#' 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
#' `factor`). For each direction specified in `abnormal` (e.g. high or low) count patients in the
#' numerator and denominator as follows:
#' \describe{
#' \item{`num`}{the number of patients with this abnormality recorded while on treatment.}
#' \item{`denom`}{the number of patients with at least one post-baseline assessment.}
#' \item{num}{the number of patients with this abnormality recorded while on treatment.}
#' \item{denom}{the number of patients with at least one post-baseline assessment.}
#' }
#' Note, the denominator includes patients that might have other abnormal levels at baseline,
#' and patients with missing baseline. Note, optionally patients with this abnormality at
Expand All @@ -23,7 +23,6 @@
#'
#' @name abnormal
#' @include formats.R
#'
NULL

#' @describeIn abnormal Statistics function which counts patients with abnormal range values
Expand Down
28 changes: 14 additions & 14 deletions R/abnormal_by_baseline.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
#' Note that `df` should be filtered to include only post-baseline records.
#'
#' 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 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:
#' * `Not <abnormal>`
#' * `denom`: the number of patients without abnormality at baseline (excluding those with missing baseline)
#' * `num`: the number of patients in `denom` who also have at least one abnormality post-baseline
#' * `<Abnormal>`
#' * `denom`: the number of patients with abnormality at baseline
#' * `num`: the number of patients in `denom` who also have at least one abnormality post-baseline
#' * `Total`
#' * `denom`: the number of patients with at least one valid measurement post-baseline
#' * `num`: the number of patients in `denom` who also have at least one abnormality post-baseline
#' 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:
#' * `Not <Abnormal>`
#' * `denom`: the number of patients without abnormality at baseline (excluding those with missing baseline)
#' * `num`: the number of patients in `denom` who also have at least one abnormality post-baseline
#' * `<Abnormal>`
#' * `denom`: the number of patients with abnormality at baseline
#' * `num`: the number of patients in `denom` who also have at least one abnormality post-baseline
#' * `Total`
#' * `denom`: the number of patients with at least one valid measurement post-baseline
#' * `num`: the number of patients in `denom` who also have at least one abnormality post-baseline
#'
#' @inheritParams argument_convention
#' @param abnormal (`character`)\cr identifying the abnormal range level(s) in `.var`.
Expand Down Expand Up @@ -58,7 +58,7 @@ d_count_abnormal_by_baseline <- function(abnormal) {
#' Please note that if the baseline variable or analysis variable contains `NA`, it is expected that `NA` has been
#' conveyed to `na_level` appropriately beforehand with `df_explicit_na()` or `explicit_na()`.
#'
#' @param na_level (`string`) \cr the explicit `na_level` argument you used in the pre-processing steps (maybe with
#' @param na_level (`string`)\cr the explicit `na_level` argument you used in the pre-processing steps (maybe with
#' `df_explicit_na()`). The default is `"<Missing>"`.
#'
#' @examples
Expand Down Expand Up @@ -140,6 +140,7 @@ s_count_abnormal_by_baseline <- function(df,

#' @describeIn abnormal_by_baseline Formatted Analysis function which can be further customized by calling
#' [rtables::make_afun()] on it. It is used as `afun` in [rtables::analyze()].
#'
#' @return [a_count_abnormal_by_baseline()] returns the corresponding list with formatted [rtables::CellValue()].
#'
#' @examples
Expand All @@ -163,7 +164,6 @@ a_count_abnormal_by_baseline <- make_afun(
#' @inheritParams argument_convention
#'
#' @examples
#'
#' # Layout creating function.
#' basic_table() %>%
#' count_abnormal_by_baseline(var = "ANRIND", abnormal = c(High = "HIGH")) %>%
Expand Down
27 changes: 14 additions & 13 deletions R/abnormal_by_marked.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Count patients with marked laboratory abnormalities
#' Count Patients with Marked Laboratory Abnormalities
#'
#' @description `r lifecycle::badge("stable")`
#'
Expand All @@ -7,27 +7,28 @@
#' Additional analysis variables are `id` (character or factor) and `direction` indicating
#' the direction of the abnormality (factor).
#' Denominator is number of patients with at least one valid measurement during
#' treatment (post-baseline), and patients in the numerator are considered as follows:
#' * For `Single, not last` and `Last or replicated`: Numerator is number of patients
#' with `Single, not last` and `Last or replicated` levels, respectively.
#' * For `Any`: Numerator is the number of patients with either single or
#' replicated marked abnormalities.
#' * For `Single, not last` and `Last or replicated`: Numerator is number of patients
#' with `Single, not last` and `Last or replicated` levels, respectively.
#' * For `Any`: Numerator is the number of patients with either single or
#' replicated marked abnormalities.
#'
#' @details Note that `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.

#'
#' @inheritParams argument_convention
#' @param category (`list`)\cr with different marked category names for single
#' and last or replicated.
#' @name abnormal_by_marked
#' and last or replicated.
#'
#' @name abnormal_by_marked
NULL

#' @describeIn abnormal_by_marked Statistics function which returns
#' the counts and fractions of patients with `Single, not last`, `Last or replicated` and `Any`
#' marked laboratory abnormalities for a single `abnormal` level.
#' the counts and fractions of patients with `Single, not last`, `Last or replicated` and `Any`
#' marked laboratory abnormalities for a single `abnormal` level.
#'
#' @return [s_count_abnormal_by_marked()] the single statistic `count_fraction`
#' with `Single, not last`, `Last or replicated` and `Any` results.
#' with `Single, not last`, `Last or replicated` and `Any` results.
#'
#' @examples
#' library(dplyr)
Expand Down Expand Up @@ -157,7 +158,7 @@ a_count_abnormal_by_marked <- make_afun(
)

#' @describeIn abnormal_by_marked Layout creating function which can be used for creating tables,
#' which can take statistics function arguments and additional format arguments (see below).
#' which can take statistics function arguments and additional format arguments (see below).
#'
#' @examples
#' map <- unique(
Expand Down
16 changes: 8 additions & 8 deletions R/abnormal_by_worst_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
#' For a certain direction (e.g. high or low) this function counts
#' patients in the denominator as number of patients with at least one valid measurement during treatment,
#' and patients in the numerator as follows:
#' * `1` to `4`: Numerator is number of patients with worst grades 1-4 respectively;
#' * `Any`: Numerator is number of patients with at least one abnormality, which means grade is different from 0.
#' * `1` to `4`: Numerator is number of patients with worst grades 1-4 respectively;
#' * `Any`: Numerator is number of patients with at least one abnormality, which means grade is different from 0.
#'
#' @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
#' the correct denominators when building the layout as it is used to define row splitting.
#' * A toxicity grade variable (e.g. `GRADE_ANL`) where all negative values from
#' `ATOXGR` are replaced by their absolute values.
#' * Prior to tabulation, `df` must filtered to include only post-baseline records with worst grade flags.
#' * A grade direction variable (e.g. `GRADE_DIR`) is required in order to obtain
#' the correct denominators when building the layout as it is used to define row splitting.
#' * A toxicity grade variable (e.g. `GRADE_ANL`) where all negative values from
#' `ATOXGR` are replaced by their absolute values.
#' * Prior to tabulation, `df` must filtered to include only post-baseline records with worst grade flags.
#'
#' @inheritParams argument_convention
#'
#' @name abnormal_by_worst_grade
#'
NULL

#' @describeIn abnormal_by_worst_grade Statistics function which counts patients with worst grade,
#' consisting of counts and percentages of patients with worst grade
#' `1` to `4`, and `Any` non-zero grade.
#'
#' @return [s_count_abnormal_by_worst_grade()] the single statistic `count_fraction` with grade 1 to 4
#' and "Any" results.
#'
Expand Down
67 changes: 31 additions & 36 deletions R/abnormal_by_worst_grade_worsen.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,22 @@ NULL
#'
#' Helper function to prepare a `df` for generate the patient count shift table
#'
#' @param adlb (`data frame`) \cr `ADLB` dataframe
#' @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.
#' * `L`: low direction only
#' * `H`: high direction only
#' * `B`: both low and high directions
#' @param adlb (`data.frame`)\cr `ADLB` dataframe
#' @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.
#' * `L`: low direction only
#' * `H`: high direction only
#' * `B`: both low and high directions
#'
#' @return [h_adlb_worsen()] returns the `adlb` `data frame` containing only the
#' 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
#' 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.
#' @return [h_adlb_worsen()] returns the `adlb` `data.frame` containing only the
#' 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
#' 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.
#' @seealso [abnormal_by_worst_grade_worsen]
#'
#' @examples
Expand Down Expand Up @@ -159,10 +156,10 @@ h_adlb_worsen <- function(adlb,
#'
#' @inheritParams argument_convention
#' @inheritParams h_adlb_worsen
#' @param baseline_var (`string`) \cr baseline lab grade variable
#' @param baseline_var (`string`)\cr baseline lab grade variable
#' @return [h_worsen_counter()] returns the counts and fraction of patients
#' whose worst post-baseline lab grades are worse than their baseline grades, for
#' post-baseline worst grades "1", "2", "3", "4" and "Any".
#' whose worst post-baseline lab grades are worse than their baseline grades, for
#' post-baseline worst grades "1", "2", "3", "4" and "Any".
#' @seealso [abnormal_by_worst_grade_worsen]
#'
#' @examples
Expand Down Expand Up @@ -261,16 +258,16 @@ h_worsen_counter <- function(df, id, .var, baseline_var, direction_var) {
}

#' @describeIn abnormal_by_worst_grade_worsen Statistics function which calculates the
#' counts and fraction of patients whose worst post-baseline lab grades are worse than
#' their baseline grades, for post-baseline worst grades "1", "2", "3", "4" and "Any".
#' counts and fraction of patients whose worst post-baseline lab grades are worse than
#' their baseline grades, for post-baseline worst grades "1", "2", "3", "4" and "Any".
#'
#' @param variables (named `list` of `string`) \cr list of additional analysis variables including:
#' * `id` (`string`): \cr subject variable name
#' * `baseline_var` (`string`): \cr name of the data column containing baseline toxicity variable
#' * `direction_var` (`string`): See `direction_var` for more detail
#' @param variables (named `list` of `string`)\cr list of additional analysis variables including:
#' * `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.
#' @return [s_count_abnormal_lab_worsen_by_baseline()] returns the
#' counts and fraction of patients whose worst post-baseline lab grades are worse than
#' their baseline grades, for post-baseline worst grades "1", "2", "3", "4" and "Any".
#' counts and fraction of patients whose worst post-baseline lab grades are worse than
#' their baseline grades, for post-baseline worst grades "1", "2", "3", "4" and "Any".
#'
#' @examples
#' library(dplyr)
Expand Down Expand Up @@ -327,10 +324,9 @@ s_count_abnormal_lab_worsen_by_baseline <- function(df, # nolint


#' @describeIn abnormal_by_worst_grade_worsen
#' Formatted Analysis function which can be further customized by
#' calling [rtables::make_afun()] on it. It is used as `afun` in [rtables::analyze()].
#' @return [a_count_abnormal_lab_worsen_by_baseline()] returns
#' the corresponding list with formatted [rtables::CellValue()].
#'
#' @return [a_count_abnormal_lab_worsen_by_baseline()] returns the corresponding list with
#' formatted [rtables::CellValue()].
#'
#' @examples
#' # Internal function - a_count_abnormal_lab_worsen_by_baseline
Expand All @@ -349,9 +345,8 @@ a_count_abnormal_lab_worsen_by_baseline <- make_afun( # nolint
.ungroup_stats = "fraction"
)

#' @describeIn abnormal_by_worst_grade_worsen Layout
#' creating function which can be used for creating tables, which can take statistics
#' function arguments and additional format arguments (see below).
#' @describeIn abnormal_by_worst_grade_worsen Layout creating function which can be used for creating tables,
#' which can take statistics function arguments and additional format arguments (see below).
#'
#' @examples
#' basic_table() %>%
Expand Down
2 changes: 1 addition & 1 deletion R/analyze_vars_in_cols.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NULL
#' @inheritParams argument_convention
#' @inheritParams rtables::analyze_colvars
#'
#' @seealso [summarize_vars], [rtables::analyze_colvars].
#' @seealso [summarize_vars], [`rtables::analyze_colvars()`].
#'
#' @export
#' @examples
Expand Down
12 changes: 6 additions & 6 deletions R/argument_convention.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@
#' `@inheritParams argument_convention`
#'
#' @param ... additional arguments for the lower level functions.
#' @param .df_row (`data frame`)\cr data frame across all of the columns for the given row split.
#' @param .df_row (`data.frame`)\cr data frame across all of the columns for the given row split.
#' @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`.
#' @param .N_row (`count`)\cr column-wise N (column count) for the full column that is passed by `rtables`.
#' @param .ref_group (`data frame` or `vector`)\cr the data corresponding to the reference group.
#' @param .ref_group (`data.frame` or `vector`)\cr the data corresponding to the reference group.
#' @param .stats (`character`)\cr statistics to select for the table.
#' @param .indent_mods (named `integer`)\cr indent modifiers for the labels.
#' @param .formats (named `character` or `list`)\cr formats for the statistics.
#' @param .labels (named `character`)\cr labels for the statistics (without indent).
#' @param .var (`string`)\cr single variable name that is passed by `rtables` when requested
#' by a statistics function.
#' @param .spl_context (`data frame`)\cr gives information about ancestor split states
#' @param .spl_context (`data.frame`)\cr gives information about ancestor split states
#' that is passed by `rtables`.
#' @param col_by (`factor`)\cr defining column groups.
#' @param conf_level (`proportion`)\cr confidence level of the interval.
#' @param data (`data.frame`)\cr the dataset containing the variables to summarize.
#' @param df (`data frame`)\cr data set containing all analysis variables.
#' @param df (`data.frame`)\cr data set containing all analysis variables.
#' @param draw (`flag`)\cr whether the plot should be drawn.
#' @param drop (`flag`)\cr should non appearing occurrence levels be dropped from the resulting table.
#' Note that in that case the remaining occurrence levels in the table are sorted alphabetically.
#' @param id (`string`) \cr subject variable name.
#' @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 (`count`) \cr it can be negative. Modifier for the default indent position for the
#' @param indent_mod (`count`)\cr it can be negative. Modifier for the default indent position for the
#' structure created by this function(subtable, content table, or row) and
#' all of that structure's children. Defaults to 0, which corresponds to the
#' unmodified default behavior.
Expand Down
7 changes: 3 additions & 4 deletions R/compare_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ s_compare <- function(x,
#' @describeIn compare_variables Method for numeric class. This uses the standard t-test
#' to calculate the p-value.
#' @return If `x` is of class `numeric`, returns a list with named items:
#' - all items from [s_summary.numeric()].
#' - `pval`: the p-value.
#' - all items from [s_summary.numeric()].
#' - `pval`: the p-value.
#' @method s_compare numeric
#'
#' @export
Expand Down Expand Up @@ -77,8 +77,7 @@ s_compare.numeric <- function(x,
#' missing values should be accounted for explicitly as factor levels.
#' @param denom (`string`)\cr choice of denominator for factor proportions,
#' can only be `n` (number of values in this row and column intersection).
#' @return If `x` is of class `factor` or converted from `character`, returns a list with
#' named items:
#' @return If `x` is of class `factor` or converted from `character`, returns a list with named items:
#' - all items from [s_summary.factor()].
#' - `pval`: the p-value.
#' @method s_compare factor
Expand Down
Loading