Skip to content
Prev 174590 / 398506 Next

Efficiently create dummy

well, you can first define a factor, and the use model.matrix(), e.g.,

fc <- factor(c("AR", "DE", "MS", "NY"))
model.matrix(~ fc)


for more info check ?model.matrix(), e.g., if you want to change the 
contrasts.

I hope it helps.

Best,
Dimitris
Rob Denniker wrote: