Skip to content

devide data into decile

3 messages · Guojun Zhu, Uwe Ligges, Frank E Harrell Jr

#
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?
#
Guojun Zhu wrote:

            
For example, the result of cut() as a new variable to the data.frame and 
afterwards split() the data.frame by the resulting factor.

Uwe Ligges
#
Uwe Ligges wrote:
Or

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

Frank