I want to create logical variables for every level of factor x
.
so from a factor x <- factor(c('apple','orange','apple','peach'))
I would get three variables each the length of x
:
apple = c(T,F,T,F)
orange = c(F,T,F,F)
peach = c(F,F,F,T)
Is there a function to do this?