Any help with this would be much appreciated.
I have four overlapping race variables that I would like to make mutually exclusive and code the remainder into a new variable mixed race variable. I've been trying to use if and ifelse and failing miserably.
white<-c(1,1,1,NA)
black<-c(0,NA,1,0)
asian<-c(0,0,0,0)
aian<- c(0,0,0,0)
white.n<-c(1,1,0,NA)
mix<-c(0,0,1,0)
df<-cbind(white,black,asian,aian,white.n,mix)
df
white black asian aian white.n mix
[1,] 1 0 0 0 1 0
[2,] 1 NA 0 0 1 0
[3,] 1 1 0 0 0 1
[4,] NA 0 0 0 NA 0
Any thoughts would be much appreciated.