separate_age_groups: Separate Age Group Column into Min and Max Age of Range

Description Usage Arguments See Also Examples

View source: R/age.R

Description

Takes the age group stored in age_group and creates two variables, age_min and age_max with the age boundaries of the group. By default, separate_age_groups() assumes that the age group definitions are separated by a dash ("-"), possibly with whitespace on either side. The separator can be specified using the sep argument.

Usage

1
2
separate_age_groups(data, age_group = age_group, ...,
  sep = "\\s*-\\s*", into = c("age_min", "age_max"))

Arguments

data

A data frame.

age_group

Unquoted column name containing the age grouping.

...

Not used other than to require explicit naming of arguments.

sep

Separator between columns.

If character, is interpreted as a regular expression. The default value is a regular expression that matches any sequence of non-alphanumeric values.

If numeric, interpreted as positions to split at. Positive values start at 1 at the far-left of the string; negative value start at -1 at the far-right of the string. The length of sep should be one less than into.

into

Character vector of column names for separated age_group. If NULL, then _min and _max will be appended to the name of the age_group column. Must be two names in the order min then max.

See Also

format_age_groups() for the specification of the age group label format and to convert age boundaries into age group labels.

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

Examples

1
2
3
4
5
6
d_age_group <- dplyr::tibble(
  id = 1:4,
  age_group = c("0 - 4", "10 - 14", "65 - 69", "85+")
)

separate_age_groups(d_age_group)

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