afun_riskdiff: Analysis function to calculate risk difference column values

View source: R/riskdiff.R

afun_riskdiffR Documentation

Analysis function to calculate risk difference column values

Description

In the risk difference column, this function uses the statistics function associated with afun to calculates risk difference values from arm X (reference group) and arm Y. These arms are specified when configuring the risk difference column which is done using the add_riskdiff() split function in the previous call to rtables::split_cols_by(). For all other columns, applies afun as usual. This function utilizes the stat_propdiff_ci() function to perform risk difference calculations.

Usage

afun_riskdiff(
  df,
  labelstr = "",
  .var,
  .N_col,
  .N_row,
  .df_row,
  .spl_context,
  .all_col_counts,
  .stats,
  .formats = NULL,
  .labels = NULL,
  .indent_mods = NULL,
  na_str = default_na_str(),
  afun,
  s_args = list()
)

Arguments

df

(data.frame)
data set containing all analysis variables.

labelstr

(string)
label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions). See rtables::summarize_row_groups() for more information.

.var

(string)
single variable name that is passed by rtables when requested by a statistics function.

.N_col

(integer(1))
column-wise N (column count) for the full column being analyzed that is typically passed by rtables.

.N_row

(integer(1))
row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed by rtables.

.df_row

(data.frame)
data frame across all of the columns for the given row split.

.spl_context

(data.frame)
gives information about ancestor split states that is passed by rtables.

.all_col_counts

(integer)
vector where each value represents a global count for a column. Values are taken from alt_counts_df if specified (see rtables::build_table()).

.stats

(character)
statistics to select for the table.

.formats

(named character or list)
formats for the statistics. See Details in analyze_vars for more information on the "auto" setting.

.labels

(named character)
labels for the statistics (without indent).

.indent_mods

(named integer)
indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.

na_str

(string)
string used to replace all NA or empty values in the output.

afun

(named list)
a named list containing one name-value pair where the name corresponds to the name of the statistics function that should be used in calculations and the value is the corresponding analysis function.

s_args

(named list)
additional arguments to be passed to the statistics function and analysis function supplied in afun.

Value

A list of formatted rtables::CellValue().

See Also

  • stat_propdiff_ci() for details on risk difference calculation.

  • Split function add_riskdiff() which, when used as split_fun within rtables::split_cols_by() with riskdiff argument set to TRUE in subsequent analyze functions calls, adds a risk difference column to a table layout.


tern documentation built on Sept. 24, 2024, 9:06 a.m.