[R] Convert continuous variable into discrete variable

Frank Harrell f.harrell at vanderbilt.edu
Mon Apr 29 13:21:12 CEST 2013

It is important to check for lack of fit of the categorized variable.  One
way to do this is to test for the additional predictive ability of the
original continuous variable after adjusting for its categorized version. 
It is very uncommon for a categorized continuous variable to fit well,
because its assumed discontinuities seldom exist in nature and most
relationships are not piecewise flat.

levanovd wrote
> Or even simpler (no need to specify labels):
> x<-runif(100,0,100) 
> u <- cut(x, breaks = c(0, 3, 4.5, 6, 8, Inf), labels = FALSE)

Frank Harrell
Department of Biostatistics, Vanderbilt University
View this message in context: http://r.789695.n4.nabble.com/Convert-continuous-variable-into-discrete-variable-tp3671032p4665699.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list