[R] Quantiles with ordered categories

matthias-gondan at gmx.de matthias-gondan at gmx.de
Tue Mar 14 21:54:42 CET 2017

I found it:

quantile(ordered(1:10), probs=0.5, type=1) 

works, because type=1 seems to round up or down, whatever. The default option for is 7, which wants to interpolate, and then produces the error. 

Two options come to my mind:

- The error message could be improved.
- The default type could be 1 if the data is from ordered categories.
- Or both.

It is probably a little thing to fix, but I lack the skills to do this myself.

Best wishes,


Von: Bert Gunter
Gesendet: Dienstag, 14. März 2017 21:34
An: matthias-gondan at gmx.de
Cc: r-help at r-project.org
Betreff: Re: [R] Quantiles with ordered categories

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, Mar 14, 2017 at 12:36 PM,  <matthias-gondan at gmx.de> wrote:
> Dear R users,
> This works:
> quantile(1:10, probs=0.5)
> This fails (obviously):
> quantile(factor(1:10), probs=0.5)
> But why do quantiles for ordered factors not work either?
> quantile(ordered(1:10), probs=0.5)
> Is it because interpolation (see the optional type argument) is not defined?

Is there an elegant workaround?
No. How can there be? By definition, all that is assumed by an ordered
factor is an ordering of the categories. How can you "interpolate" in
ordered(letters[1:3]) . ASAIK there is no "a.5"  .

-- Bert

> Thank you.
> Best wishes,
> Matthias
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list