h_split_by_subgroups {tern} | R Documentation |
Split data frame by subgroups
Description
Split a data frame into a non-nested list of subsets.
Usage
h_split_by_subgroups(data, subgroups, groups_lists = list())
Arguments
data |
( |
subgroups |
( |
groups_lists |
(named |
Details
Main functionality is to prepare data for use in forest plot layouts.
Value
A list with subset data (df
) and metadata about the subset (df_labels
).
Examples
df <- data.frame(
x = c(1:5),
y = factor(c("A", "B", "A", "B", "A"), levels = c("A", "B", "C")),
z = factor(c("C", "C", "D", "D", "D"), levels = c("D", "C"))
)
formatters::var_labels(df) <- paste("label for", names(df))
h_split_by_subgroups(
data = df,
subgroups = c("y", "z")
)
h_split_by_subgroups(
data = df,
subgroups = c("y", "z"),
groups_lists = list(
y = list("AB" = c("A", "B"), "C" = "C")
)
)
[Package tern version 0.9.5 Index]