Skip to contents

Collapse race down to the EPHT's allowable values: "W", "B", "O", "U"

Usage

collapse_race(race, na_is_unknown = TRUE)

Arguments

race

Character string of the race value

na_is_unknown

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

Value

Race 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

Race 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:

  • white, caucasian -> "W"

  • blackorafricanamerican, black, africanamerican -> "B"

  • americanindianoralaskanative, americanindian, alaskanative -> "O"

  • asian -> "O"

  • nativehawaiianorotherpacificislander, nativehawaiian, otherpacificislander, pacificislander -> "O"

  • other -> "O"

  • unknown, unk, u -> "U"

Examples

collapse_race("Asian")
#> [1] "O"