noamross / zero-dependency-problems

Real-world code problems in R, without dependencies
79 stars 25 forks source link

many-dichotomous-variables #12

Open noamross opened 9 years ago

noamross commented 9 years ago

https://github.com/noamross/zero-dependency-problems/blob/master/R/many-dichotomous-variables.md

I have a dataframe with around 8000 rows. Variable X is a categorical variable with values ranging from 1 to 200. I want to create 200 dichotomous variables (0/1) based on X.

Thus X001 == 1 if X == 1; & X001 == 0 if X !=1. Any suggestions how to do this?

Thanks for your time.