filter_age_groups: Filter Data by Age Range

Description Usage Arguments See Also Examples

View source: R/age.R

Description

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.

Usage

1
2
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

Other age processors: complete_age_groups, format_age_groups, recode_age_groups, separate_age_groups, standardize_age_groups

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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)

d_age_group %>%
  filter_age_groups(age_gt = 65)

# Notice that the "65 - 69" group is *not* included
d_age_group %>%
  filter_age_groups(age_lt = 66)

GerkeLab/fcds documentation built on July 30, 2020, 7:04 p.m.