GroupConditions {stenR} | R Documentation |
Conditions for observation grouping
Description
With help of this function you can create GroupingConditions object, holding the basis of observation grouping. Objects of this class can be provided to complex functions to automatically group observations accordingly.
Usage
GroupConditions(
conditions_category,
...,
force_disjoint = TRUE,
force_exhaustive = FALSE,
.dots = list()
)
## S3 method for class 'GroupConditions'
print(x, ...)
## S3 method for class 'GroupConditions'
as.data.frame(x, ...)
Arguments
conditions_category |
chracter value describing character of the group conditions. Mainly informative. |
... |
additional arguments to be passed to or from methods. |
force_disjoint |
boolean indicating if the condition formulas by default
should be handled with |
force_exhaustive |
boolean indicating if groups exhaustiveness should
be forced in case when there are observations that don't pass any of the provided
conditions. If |
.dots |
formulas in form of a list |
x |
|
Value
GroupConditions object
Examples
# create GroupConditions with formula-style conditions per each group
sex_grouping <- GroupConditions(
conditions_category = "Sex",
"M" ~ sex == "M",
"F" ~ sex == "F",
"O" ~ !sex %in% c("M", "F")
)
print(sex_grouping)
# GroupConditions can also mark if the groups should be handled by default
# with forced disjoint (default `TRUE`) and exhaustiveness (default `FALSE`)
age_grouping <- GroupConditions(
conditions_category = "Age",
"to 20" ~ age < 20,
"20 to 40" ~ age >= 20 & age <= 40,
"40 to 60" ~ age >= 40 & age < 60,
force_disjoint = FALSE,
force_exhaustive = TRUE
)
print(age_grouping)