clean_period: Tidy period labels

Description Usage Arguments Details Value See Also Examples

View source: R/clean.R

Description

Try to parse period labels and convert them to the format used by the dem packages.

Usage

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

clean_period_df(x, language = "English")

Arguments

x

A numeric or character vector.

language

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

Details

Open intervals such as "<2020" or "2020+" are not allowed.

By default, clean_period 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_period_df returns a data frame showing how each unique element in x is interpreted by function clean_period and whether the element can be interpreted as a valid period label.

Value

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

See Also

is_valid_period, clean_age, clean_cohort

Examples

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

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