Create categorial variable in R based on range

Posted by Stedy on Stack Overflow See other posts from Stack Overflow or by Stedy
Published on 2010-04-15T17:36:23Z Indexed on 2010/04/15 18:03 UTC
Read the original article Hit count: 176

Filed under:

I have a dataframe with a column of integers that I would like to use as a reference to make a new categorical variable. I want to divide the variable into three groups and set the ranges myself (ie 0-5, 6-10, etc). I tried cut but that divides the variable into groups based on a normal distribution and my data is right skewed. I have also tried to use if/then statements but this outputs a true/false value and I would like to keep my original variable. I am sure that there is a simple way to do this but I cannot seem to figure it out. Any advice on a simple way to do this quickly?

© Stack Overflow or respective owner

Related posts about r