On 01/26/2012 07:23 PM, citadel wrote:
I am new to R, and I am trying to cut a continuous variable BMI into
different categories and can't figure out how to use it. I would like to cut
it into four groups:<20, 20-25, 25-30 and>= 30.  I am having difficulty
figuring the code for<20 and>=30? Please help. Thank you.

Hi citadel,
Assuming that you only have positive numbers and they are all less than 100:

BMIcut<-cut(BMI,breaks=c(0,20,25,30,100),
 include.lowest=TRUE,right=FALSE)

This will give you
 >=0-20, >=20-<25, >=20-<30, >=30-<100

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to