clean_cohort: Clean up cohort labels

Description Usage Arguments Details Value See Also Examples

View source: R/clean.R

Description

Parse cohort labels and convert them to the format used by the dem packages.

Usage

1
2
3
clean_cohort(x, language = "English")

clean_cohort_df(x, language = "English")

Arguments

x

A numeric or character vector.

language

The language in which text labels are written. Defaults to English.

Details

Intervals that are open on the left such as "<2000" are allowed. Intervals that are open on the right such as "2000+" are not.

By default, clean_cohort assumes that any text labels are written in English. However, other languages can be specified using the language argument. Current choices are ADD OVER TIME.

Function clean_cohort_df returns a data frame showing how each unique element in x is interpreted by function clean_cohort and whether the element can be interpreted as a valid cohort label.

Value

clean_cohort returns a character vector with the same length as x in which labels that have been parsed are translated to dem formats. clean_cohort_df returns a data frame with columns "input", "output", and "is_valid".

See Also

is_valid_cohort, clean_age, clean_period

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- c("before 2000", 
       "after 2000",  
       "Millenials",
       "2020 Jan",
       "Q3 2020",
       "January 2020",
       "2025 first quarter",
       "untranslatable",
       "2020-2025")
x
clean_cohort(x)
clean_cohort_df(x)

johnrbryant/demprep documentation built on Dec. 31, 2021, 11:58 a.m.