mutate(
wbhao = case_when(
hispan >= 100 & hispan <= 612 ~ 3, # Hispanic or latino
race == 100 ~ 1, # White
race %in% c(200, 801, 805, 806, 807, 810, 811, 814, 816, 818) ~ 2, # Black
race %in% c(650, 651, 652, 803, 804, 808, 809, 812, 813, 817, 819) ~ 4, # AAPI
TRUE ~ 5
),
wbhao = haven::labelled(wbhao, c(
"White" = 1,
"Black" = 2,
"Hispanic" = 3,
"AAPI" = 4,
"Other" = 5
))
)Coding race and ethnicity variables
Recoding for ASEC
Recoding for ACS (via IPUMS)
There are two ways to recode ACS race categories, the first is using the race and raced variables (raced gets automatically downloaded when you include the race variable in your sample), and the second is using race and the ‘rac’ variable series (i.e. racblk, racasian, racpacis, racamind).
Using race and raced:
mutate(
wbhao = case_when(
hispan %in% c(1,2,3,4) ~ 3,
race == 1 ~ 1,
race == 2 ~ 2,
raced >= 830 & raced <= 845 ~ 2,
raced >= 901 & raced <= 904 ~ 2,
raced >= 930 & raced <= 936 ~ 2,
raced >= 950 & raced <= 955 ~ 2,
raced >= 970 & raced <= 973 ~ 2,
raced >= 980 & raced <= 983 ~ 2,
raced %in% c(917, 985, 986, 990, 991) ~ 2,
race %in% c(4,5,6) ~ 4,
raced >= 810 & raced <= 825 ~ 4,
raced >= 850 & raced <= 855 ~ 4,
raced >= 860 & raced <= 899 ~ 4,
raced >= 910 & raced <= 915 ~ 4,
raced >= 920 & raced <= 927 ~ 4,
raced >= 940 & raced <= 944 ~ 4,
raced >= 960 & raced <= 964 ~ 4,
raced %in% c(905, 974, 975, 976, 984) ~ 4,
TRUE ~ 5
),
wbhao = labelled(wbhao, c(
"White" = 1,
"Black" = 2,
"Hispanic" = 3,
"AAPI" = 4,
"Other" = 5
))
)Using race and the ‘rac’ variable series
mutate(
wbhao = case_when(
hispan %in% c(1,2,3,4) ~ 3,
race == 1 ~ 1,
racblk == 2 ~ 2,
racasian == 2 ~ 4,
racpacis == 2 ~ 4,
TRUE ~ 5
),
wbhao = labelled(wbhao, c(
"White" = 1,
"Black" = 2,
"Hispanic" = 3,
"AAPI" = 4,
"Other" = 5
))
)