[R] Coding several dummy variables into a single categorical variable
Mosi Ifatunji
ifatunji at gmail.com
Sun Sep 22 20:40:55 CEST 2013
Colleagues,
I have generated several dummy variables:
n$native0 <- 1 * (n$re=="white" & n$usborn=="yes")
n$native1 <- 1 * (n$re=="afam" & n$usborn=="yes")
n$native2 <- 1 * (n$re=="carib" & n$usborn=="yes")
n$native3 <- 1 * (n$re=="carib" & n$usborn=="no")
I would now like to combine these into a single categorical variable where the new variable would be n$native.
And values of native would be 0 through 3, where n$native0 would be a 0 value on n$native, n$native1 would be a 1 value on n$native etc.
Any help would be greatly appreciated.
-- Mosi
More information about the R-help
mailing list