Welcome to the Genome Toolbox! I am glad you navigated to the blog and hope you find the contents useful and insightful for your genomic needs. If you find any of the entries particularly helpful, be sure to click the +1 button on the bottom of the post and share with your colleagues. Your input is encouraged, so if you have comments or are aware of more efficient tools not included in a post, I would love to hear from you. Enjoy your time browsing through the Toolbox.

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