"Alberto Monteiro" <[EMAIL PROTECTED]> writes:

> 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)

Have a look at

> N <- 2
> table(cut(x,quantile(x,seq(0,1,1/N)), include.lowest=TRUE))

[-2.78,0.205]  (0.205,2.22]
           50            50

> table(cut(x,c(-Inf,quantile(x,(1:(N-1))/N),Inf)))

(-Inf,0.205] (0.205, Inf]
          50           50

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])                  FAX: (+45) 35327907

______________________________________________
[email protected] 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.

Reply via email to