Skip to contents

Convert Race to Numeric Code

Usage

racen(racec)

Arguments

racec

Race character

Value

the standard yspec numeric value for the inputted Race character

Details

Default mapping: White = 1, Black = 2, Asian = 3, American Native = 4, Pacific Islander = 5, Other = 6. "UNKNOWN" and NA map to the missing value indicator (getOption("scicalc.missing_value", -999)). Any other value is treated as unspecified: it maps to NA and triggers a warning.

The scicalc.racen_config option (a named numeric vector) customizes the mapping. A name matching a built-in category ("white", "black", "asian", "american native", "pacific islander", "other") overrides that category's code (synonyms included). Any other name adds a new exact-match category. For example options(scicalc.racen_config = c("WHITE" = 2, "JAPANESE" = 7)).

Examples

racen("WHITE") # 1
#> [1] 1

racen("BLACK") # 2
#> [1] 2

racen("ASIAN") # 3
#> [1] 3

racen("AMERICAN INDIAN OR ALASKA NATIVE") # 4
#> [1] 4

racen("PACIFIC ISLANDER") # 5
#> [1] 5

racen("OTHER") # 6
#> [1] 6

racen("UNKNOWN") # default missing value
#> [1] -999