decode_ethnorace: Convert Race & Ethnicity Codes to Single Labels

Description Usage Arguments Details Value Author(s) See Also

View source: R/panthr.r

Description

decode_ethnorace formats both the RACE_CODES and ETHNIC_CODES fields by evaluating two scalar values or vectors of values of equal length containing race and ethnicity codes. Missing values for both race and ethnicity, as well as missing race codes and ethnicity of 1, are converted to Not Reported. In instances where more than one race or ethnicity is evaluated, the value is labeled Two or More Races.

Usage

1
decode_ethnorace(race, ethnicity, ethnic.precedence = TRUE)

Arguments

race

A scalar or vector of length n and class character comprised of race codes, e.g. B, Z, or some permutation of race codes, e.g. WZI.

ethnicity

A scalar or vector of length n and class character or numeric that contain an ethnicity code, i.e. 1 or 2.

ethnic.precedence

A logical value indicating whether ethnicity takes precedence over one or more races. As Hispanic or Latinx is the only other ethnicity, any race or permutation of race codes will be overridden if TRUE. Defaults to ethnic.precedence = TRUE.

Details

Output may be made categorical using function factor or as.factor. This function also allows for easily tallying counts using, e.g., function table.

Ethnicity codes other than 1 or 2 are coerced to NA (missing) rather than converted to Not Reported. Likewise, unrecognized race codes are coerced to NA (missing) values rather than Not Reported. In both instances, a warning is thrown.

In instances were race codes are detected in argument ethnicity = or ethnicity codes are detected in argument race =, evaluation is halted and an error is thrown.

Value

A scalar or vector of values of length n and class character containing a single label describing the combined race and ethnicity code.

NULL values are converted into the character string: Not Reported.

Author(s)

Jamison R. Crawford, Institutional Research Associate, Georgia State University

See Also

table


jamisoncrawford/panthr documentation built on March 9, 2020, 6:18 p.m.