[R] replace with quantile value for a large data frame...

2011-03-13 Thread Ram H. Sharma
Dear R-Experts I am sure this might look simple question for experts, at least is problem for me. I have a large data frame with over 1000 variables and each have different distribution( i.e. have different quantile). I want to create a new grouped data frame, where the new variables where the

Re: [R] replace with quantile value for a large data frame...

2011-03-13 Thread Dimitris Rizopoulos
one way is the following: X1 - c(1:10) X2 - c(11:20) X3 - c(21:30) X4 - c(31:40) X5 - c(41:50) DF - data.frame(X1, X2, X3, X4, X5) as.data.frame(sapply(DF, function (x) { qx - quantile(x) cut(x, qx, include.lowest = TRUE, labels = 1:4) })) You may also have a look at function