Skip to contents

Collapse common ethnicity values to the EPHT's allowable values: "H", "NH", "U"

Usage

collapse_ethnicity(ethnicity, na_is_unknown = TRUE)

Arguments

ethnicity

Character string of the ethnicity value.

na_is_unknown

Convert NAs to "U" or leave as-is, default is TRUE.

Value

Ethnicity string or NA_character_

Details

If there are any other values, they will be converted to "U". NULL or NA values can be converted to "U" or left as NA_character_

Ethnicity Values

Character strings are converted to lowercase and stripped of any non-word characters. This is to ensure that the values are standardized before comparison.

Common values that get converted are:

  • hispanic, hisp, h -> "H"

  • nonhispanic, nonhisp, nh -> "NH"

  • unknown, unk, u -> "U"

See also

Examples

collapse_ethnicity("Hispanic")
#> [1] "H"