Re: [R] Convert continuous variable into discrete variable

2013-04-29 Thread Frank Harrell
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

Re: [R] Convert continuous variable into discrete variable

2011-07-15 Thread Dennis Murphy
Hi: x<-runif(100,0,100) u <- cut(x, breaks = c(0, 3, 4.5, 6, 8, Inf), labels = c(1:5)) Based on the x I obtained, > table(u) u 1 2 3 4 5 3 2 1 2 92 cut() or findInterval() are the two basic functions for discretizing a numeric variable. HTH, Dennis On Fri, Jul 15, 2011 at 2:29 PM, Mi

[R] Convert continuous variable into discrete variable

2011-07-15 Thread Michael Haenlein
Dear all, I have a continuous variable that can take on values between 0 and 100, for example: x<-runif(100,0,100) I also have a second variable that defines a series of thresholds, for example: y<-c(3, 4.5, 6, 8) I would like to convert my continuous variable into a discrete one using the thres