[R] How do I use the cut function to assign specific cut points?
Jim Lemon
jim at bitwrit.com.au
Thu Jan 26 10:25:56 CET 2012
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
More information about the R-help
mailing list