I'm a bit confused on how to populate my new column based on character combinations I have from each of my other columns.
Here is my original dataframe:
df <- data.frame('Hispanic'=c("N", "Y", "N", "N"), 'Black'=c("Y", "N", "N", "Null"), 'Asian'=c("N", "Y", "N", "N"),
'HN'=c("N", "N", "N", "N"), 'AN'=c("N", "N", "N", "Y"), 'White'=c("N", "Y", "N", "Null"),
'NA'=c("N", "N", "Y", "Y"))
I want to code the variables in the new column based on different combinations of race and ethnicity. Specifically I'm trying to get these factors into the categories of Black (Non-Hispanic), Asian (Non-Hispanic), Native Hawaiian (Non-Hispanic), American Indian/Alaska Native (Non-Hispanic), Multiracial (Non-Hispanic) and Hispanic. So whenever a record has Hispanic as a yes, the populated value should just be Hispanic but if the value is a no it should detail either the single race selected with Non-Hispanic (ex: Black, NH) or if they selected more than one race it would be multiracial and Non-Hispanic (Ex: Multiracial, NH).
The goal is to get something that looks like the results below:
df1 <- data.frame('Hispanic'=c("N", "Y", "N", "N"), 'Black'=c("Y", "N", "N", "Null"), 'Asian'=c("N", "Y", "N", "N"),
'HN'=c("N", "N", "N", "N"), 'AN'=c("N", "N", "N", "Y"), 'White'=c("N", "Y", "N", "Null"),
'NA'=c("N", "N", "Y", "Y"),
'R_E'=c("Black, NH", "Hispanic", "Native American, NH", "Multi-racial, NH" ))