Additional parameters within analysis and content functions (afun/cfun)
Source: R/colby_constructors.R
additional_fun_params.RdIt is possible to add specific parameters to afun and cfun, in analyze() and summarize_row_groups(),
respectively. These parameters grant access to relevant information like the row split structure (see
spl_context) and the predefined baseline (.ref_group).
Details
We list and describe all the parameters that can be added to a custom analysis function below:
- .N_col
Column-wise N (column count) for the full column being tabulated within.
- .N_total
Overall N (all observation count, defined as sum of column counts) for the tabulation.
- .N_row
Row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting).
- .df_row
data.framefor observations in the row group being analyzed (i.e. with no column-based subsetting).- .var
Variable being analyzed.
- .ref_group
data.frameor vector of subset corresponding to theref_groupcolumn including subsetting defined by row-splitting. Only required/meaningful if aref_groupcolumn has been defined.- .ref_full
data.frameor vector of subset corresponding to theref_groupcolumn without subsetting defined by row-splitting. Only required/meaningful if aref_groupcolumn has been defined.- .in_ref_col
Boolean indicating if calculation is done for cells within the reference column.
- .spl_context
data.framewhere each row gives information about a previous 'ancestor' split state. See spl_context.- .alt_df_row
data.frame, i.e. thealt_counts_dfafter row splitting. It can be used with.all_col_exprsand.spl_contextinformation to retrieve current faceting, but foralt_count_df. It can be an empty table if all the entries are filtered out.- .alt_df
data.frame,.alt_df_rowbut filtered by columns expression. This data present the same faceting of main datadf. This also filtersNAs out if related parameters are set to do so (e.g.inclNAsinanalyze()). Similarly to.alt_df_row, it can be an empty data.frame if all the entries are filtered out.- .alt_df_full
data.frame, the fullalt_counts_dfas passed intobuild_table. Unlike.alt_dfand.alt_df_row, this parameter can be used in cases where the variables required for row splitting are not present inalt_counts_df.- .all_col_exprs
List of expressions. Each of them represents a different column splitting.
- .all_col_counts
Vector of integers. Each of them represents the global count for each column. It differs if
alt_counts_dfis used (seebuild_table()).
For the .alt_df* family of parameters, these will be passed data
subsets based on df if no alt_counts_df is specified in the
build_table call. In rtables versions <= 0.6.16 this resulted in an error.
Note
If any of these formals is specified incorrectly or not present in the tabulation machinery, it will be
treated as if missing. For example, .ref_group will be missing if no baseline is previously defined during
data splitting (via ref_group parameters in, e.g., split_rows_by()). Arguments derived from
the alt_counts_df will be passed subsets of the primary data (df) when no alt_counts_df is provided
to build_table().