Create a custom splitting function suitable for creating risk
difference columns against one or more comparators. This is used
within col_struct_w_risk_diffs.
Arguments
- colspan_trt_map
(
data.frame)
A data.frame defining the active and non-active groups of treatment arms, including combination arms defined incombo_levels_map, as returned bycreate_colspan_map().- combo_levels_map
(
data.frameorNULL)
NULL (the default) or a data.frame indicating combination levels to added to some or all blocks of comparisons. See Details.- comp_level_map
(
data.frameorNULL)
A data.frame with columnsactiveandcomparatorindivating which risk difference comparisons to include in the column structure, orNULL(the default), indicating all active vs non-active pairwise comparisons as definedcolspan_trt_maptreatment groupings.- .pre
(list)
A list of additional preprocessing functions to be provided tomake_split_fun. Defaults tolist().- .post
(list)
A list of additional post-processing functions to be provided tomake_split_funafter those which provide this function's primary multi-comparator functionality. Defaults tolist()- df
(
data.frame)
Data used to derive the available levels for the splitting variablespl_varand to construct the default comparison map whencomp_level_mapis not provided.- spl_var
(
character(1))
Name of the splitting variable (typically the treatment variable) whose levels define active and comparator groups.- ref_lvls
(
character)
The level names to be treated as reference (control) groups. Comparisons will be formed against these levels.- combo_map
(
data.frame)
A combination levels map (i.e., the value passed tocombo_levels_map) used to include virtual combination levels in the default comparison map.
Value
A split function suitable for use in both split_rows_by
and split_cols_by.
For make_dflt_comp_map(), a data.frame with columns
active, comparator, active_is_combo, and comparator_is_combo,
listing the comparisons to keep and whether either side is a virtual
combination level.
Details
This split function is intended to create a set of risk difference
or similar columns. As such it will automatically exclude the facet
for each comparator level (e.g., Placebo vs Placebo) as determined
by the last element of each element of comp_level_paths.
Further control of facets is provided by comp_level_map. If
NULL (the default), all non-control/reference groups will be
compared pairwise with all control/reference groups as defined by
the grouping in colspan_trt_map.
If specified, comp_level_map must be a data.frame (including
tbl_df) with three columns:
active- (character) the value to be compared to a reference level,comparator- (character) the level that should be compared against, andactive_is_combo- (logical) is the level specified inactivea virtual combination level.comparator_is_combo- (logical) is the level specified incomparatora virtual combination level.
If a data.frame with only the active and comparator columns
is given for comp_level_map, active_is_combo and
comparator_is_combo are inferred from colspan_trt_map.
If any rows of comp_level_map have active_is_combo == TRUE or
comparator_is_combo, the relevant values in those rows must
also appear in combo_levels_map with the correct level for
comp_level (or the select_all_levels sentinel value which
indicates inclusion for all comparators).
If specified, combo_levels_map must be a data.frame (including tbl_df)
with the following columns:
valname- (character) The name(s) for the combination level(s),label- (character) the label(s) for the combination level(s),levelcombo- (listofcharacter) the levels of the split variable to be combined, orselect_all_levelsfor all levels,exargs- (list) the extra_args values for each combo level. If not present this will be assumed to belist()for all combo levels.compare_against- (listofcharacter) Optional. The reference level(s) the combo level should be compared against, orselect_all_levelsfor inclusion against all comparators.is_control- (logical) Optional. Is this combination level going to be used as a reference level (must appear as the last element in one ofcomp_level_pathsif so).
When specifying combo_levels_map if the compare_against column
is omitted, comparison against all reference levels will be
performed for all combination levels. If is_control is omitted,
it will be assumed as FALSE for all combination levels.
Order of combination levels when multiple are present for a single
comparator, as well as their position relative to non-combination
comparisons, is determined by row order in combo_levels_map.
Labels and names of comparison columns involving combination levels
will be automatically computed in the form of
"<combo level name/label> vs <ref group name>". Note currently
ref group name is always used as it needs to be inferable from
colspan_trt_map.
The comparator reference path is calculated based on
colspan_trt_map and then added as ref_path to the extra_args
associated with generated facet. As such, analysis (or content)
functions used underneath a split using the generated split
function must accept either ref_path or ....
Note
It is not currently possible to use a virtual combination level as a comparator/reference group. If you need this functionality please contact the maintainers by filing an issue at https://github.com/johnsonandjohnson/junco/issues
See also
Other riskdiff_col_struct:
grouped_cols_w_diffs()
