This split function constructor creates a split function which trims levels of a variable to reflect restrictions on the possible combinations of two or more variables which the data is split by (along the same axis) within a layout.
Details
When splitting occurs, the map is subset to the values of all previously performed splits. The levels of the variable being split are then pruned to only those still present within this subset of the map representing the current hierarchical splitting context.
Splitting is then performed via the keep_split_levels()
split function.
Each resulting element of the partition is then further trimmed by pruning values of any remaining variables specified in the map to those values allowed under the combination of the previous and current split.
Examples
map <- data.frame(
LBCAT = c("CHEMISTRY", "CHEMISTRY", "CHEMISTRY", "IMMUNOLOGY"),
PARAMCD = c("ALT", "CRP", "CRP", "IGA"),
ANRIND = c("LOW", "LOW", "HIGH", "HIGH"),
stringsAsFactors = FALSE
)
lyt <- basic_table() %>%
split_rows_by("LBCAT") %>%
split_rows_by("PARAMCD", split_fun = trim_levels_to_map(map = map)) %>%
analyze("ANRIND")
tbl <- build_table(lyt, ex_adlb)