I don't understand why 'quantile' works in this case:

> tt <- rep(c('a','b'),c(10,3))
> sapply(0:6/6,function(q) quantile(tt,probs=q,type=1))
       0% 16.66667% 33.33333%       50% 66.66667% 83.33333%      100%
      "a"       "a"       "a"       "a"       "a"       "b"       "b"
and also

> quantile(tt,0:5/5,type=1)
  0%  20%  40%  60%  80% 100%
 "a"  "a"  "a"  "a"  "b"  "b"

but gives an error in this, which I would have thought equivalent to the
first case above:

> quantile(tt,0:6/6,type=1)
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
  argument is not a numeric vector

I could of course write something like
sort(tt)[seq(1,length(tt),length.out=7)] -- but I'm wondering why quantile
fails in this case.

Thanks,

            -s

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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