[R] devide data into decile

Frank E Harrell Jr f.harrell at vanderbilt.edu
Tue May 9 14:08:46 CEST 2006


Uwe Ligges wrote:
> Guojun Zhu wrote:
> 
> 
>>I guess this is really basic.  But I do not find an
>>answer yet.  I have a big data.frame.  I would like to
>>divede them into 10 deciles accounding to one of its
>>member.  Then I need a number for each decile with
>>some computaion within each group.  How to devide it?
> 
> 
> For example, the result of cut() as a new variable to the data.frame and 
> afterwards split() the data.frame by the resulting factor.

Or

library(Hmisc)
xg <- cut2(x, g=10)    # labels deciles nicely

Frank

> 
> Uwe Ligges
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list