Pages

Thursday, May 30, 2013

How to Create Indicator (Dummy) Variables in R

Countless times when performing an analysis in R, I need to create indicator variables to run a regression.  I usually do this manually, but today I came across a way to have R do this for me.  Basically, all you need to do is to use the factor() command.  Here is a quick example where I create indicator variables from ethnicity coded as 0,1,2.

No comments:

Post a Comment