I have just started to learn R and I am trying to create a new variable + using ifelse.
nlsy$ethnicity <- as.factor(ifelse(nlsy$race_ethnicity=="Black", "Black",
ifelse(nlsy$race_ethnicity=="Hispanic", "Hispanic",
ifelse(nlsy$race_ethnicity=="Non-Black / Non-Hispanic" & nlsy$race_ethnicity="White", "White", "Other"))))
case_whenfromdplyrto avoid nestedifelsestatements, but it would also be good to see some sample data to better understand what you are trying to do here.nlsy$race_ethnicity="White", which actually should benlsy$race_ethnicity== "White". Also maybe the condition should be|(OR) rather than&(AND).