The predicate is evaluated in a dplyr::summarise() context per group
(when a formula) or receives a grouped data frame (when a function). Groups
where the predicate returns TRUE are kept; all rows in failing groups are
removed.
Arguments
- criteria
A
cf_criteriaobject (orNULLto start a new one).- by
One or more column names (character vector) to group by; supply more than one for composite (multi-column) grouping.
- predicate
A one-sided formula using summary functions (
n(),mean(),n_distinct(), etc.) or a function that receives a grouped data frame and returns a tibble with columns<by>and.pass.- label
A short human-readable description of this criterion.
- category
An optional string grouping this step with others for display.
NULLleaves it uncategorised.- reason
An optional short description of the rows this step removes, shown in diagram exclusion boxes.
NULL(default) useslabelfor exclusion steps; for inclusion steps it should be set. See the Labels section.
See also
Other criteria builders:
cf_criteria(),
cf_criterion(),
check_criteria(),
exclude(),
group_exclude(),
include(),
randomise(),
select_within()
Examples
cf_criteria() |>
group_include(by = "cluster_id", ~ n() >= 5, label = "Cluster size >= 5")
#> Cohort criteria pipeline (1 step)
#> 1. [+][~] (group_include) [by: cluster_id] Cluster size >= 5
#> n() >= 5