Dear R-List,
I would like to recode my data according to quantile breaks, i.e. all data
within the range of 0%-25% should get a 1, 25%-50% a 2 etc.
Is there a nice way to do this with all columns in a dataframe.
e.g.
df-
Hi Alain,
The following should get you started:
apply(df[,-1], 2, function(x) cut(x, breaks = quantile(x), include.lowest =
TRUE, labels = 1:4))
Check ?cut and ?apply for more information.
HTH,
Jorge.-
On Tue, Feb 19, 2013 at 9:01 PM, D. Alain wrote:
Dear R-List,
I would like to recode
: D. Alain dialva...@yahoo.de
To: Mailinglist R-Project r-help@r-project.org
Cc:
Sent: Tuesday, February 19, 2013 5:01 AM
Subject: [R] recode data according to quantile breaks
Dear R-List,
I would like to recode my data according to quantile breaks, i.e. all data
within the range of 0%-25
3 matches
Mail list logo