Split functions provide the work-horse for rtables
's generalized
partitioning. These functions accept a (sub)set of incoming data, a split
object, and return 'splits' of that data.
Custom Split Functions
Split functions provide the work-horse for rtables
's generalized
partitioning. These functions accept a (sub)set of incoming data, a split
object, and return 'splits' of that data.
User-defined custom split functions can perform any type of computation on the incoming data provided that they meed the contract for generating 'splits' of the incoming data 'based on' the split object.
Split functions are functions that accept:
data.frame of incoming data to be split
a Split object. this is largely an internal detail custom functions will not need to worry about,
but obj_name(spl)
, for example, will give the name of the split as it will appear in paths in the resulting table
Any pre-calculated values. If given non-null values, the values returned should match these. Should be NULL in most cases and can likely be ignored
Any pre-calculated value labels. Same as above for values
If TRUE
, resulting splits that are empty should be removed
a data.frame describing previously performed splits which collectively arrived at df
The function must then output a named list
with the following elements:
The vector of all values corresponding to the splits of df
a list of data.frames representing the groupings of the actual observations from df
.
a character vector giving a string label for each value listed in the values
element above
If present, extra arguments to be passed to summary and analysis functions
whenever they are executed on the corresponding element of datasplit
or a subset thereof
One way to generate custom splitting functions is to wrap existing split functions and modify either the incoming data before they are called, or their outputs.