Filters data to include persons with ages in the range between age_gt and age_lt. If age_group has not been expanded into min and max ages of the range, the input data is first passed to separate_age_groups(). If the boundary age lies within a group, that group is not included in the output.

filter_age_groups(data, age_gt = 0, age_lt = Inf,
  age_group = age_group)

Arguments

data

A data frame.

age_gt

Youngest age (inclusive).

age_lt

Eldest age (inclusive).

age_group

Unquoted column name containing the age grouping.

See also

Examples

d_age_group <- dplyr::tibble( id = 1:4, age_group = c("0 - 4", "10 - 14", "65 - 69", "85+") ) d_age_group %>% filter_age_groups(age_gt = 0, age_lt = 15)
#> # A tibble: 2 x 2 #> id age_group #> <int> <chr> #> 1 1 0 - 4 #> 2 2 10 - 14
d_age_group %>% filter_age_groups(age_gt = 65)
#> # A tibble: 2 x 2 #> id age_group #> <int> <chr> #> 1 3 65 - 69 #> 2 4 85+
# Notice that the "65 - 69" group is *not* included d_age_group %>% filter_age_groups(age_lt = 66)
#> # A tibble: 2 x 2 #> id age_group #> <int> <chr> #> 1 1 0 - 4 #> 2 2 10 - 14