[R] Simple monovariate classification?

rgunton at dijon.inra.fr rgunton at dijon.inra.fr
Wed Jul 8 17:19:22 CEST 2009


I'm looking for an R function that simply recodes a quantitative  
variable into a number of classes according to specified break-points.  
  Obviously I can do this using nested ifelse() commands, but I want  
to write it into a function where I can't pre-specify the number of  
classes.  Is there an obvious way to do this?

An example to clarify: how to convert c(0,10,5,1,9,6) to  
c(1,3,2,1,3,2) by specifying "breaks"=c(2.5,7.5) - or something like  
that.

Thanks,

Richard Gunton.
INRA-Dijon, France




More information about the R-help mailing list