[R] Partition into quantiles

Frank E Harrell Jr f.harrell at vanderbilt.edu
Thu Oct 5 15:51:10 CEST 2006


David Barron wrote:
> You might also want to look at the function quantcut in the gtools
> package (part of the gregmisc bundle).

Also, cut2 in Hmisc will do this and will label the intervals compactly.

Frank

> 
> 
> 
> On 05/10/06, Alberto Monteiro <albmont at centroin.com.br> wrote:
>> Is there any function that divides a sample into N quantiles?
>>
>> For example, for N = 2, this would be the solution:
>>
>> x <- rnorm(100)
>> m <- median(x)
>> q <- ifelse(x <= median, 1, 2)
>>
>> Alberto Monteiro
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 


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



More information about the R-help mailing list