Re: [R] Quantiles with ordered categories

2017-03-16 Thread Martin Maechler
Martin Maechler ETH Zurich > Best wishes, > Matthias > Von: Bert Gunter > Gesendet: Dienstag, 14. März 2017 21:34 > An: matthias-gon...@gmx.de > Cc: r-help@r-project.org > Betreff: Re: [R] Quantiles with ordered categories > Inline.

Re: [R] Quantiles with ordered categories

2017-03-14 Thread William Dunlap via R-help
You could round the quantiles of the codes of the ordered factor to come up with a reasonable result. E.g., quantile.ordered <- function(x, ...) ordered(levels(x)[as.integer(quantile(as.integer(x), ...))], levels=levels(x)) > unCut <- log2(2:30) > Cut <- cut(unCut, breaks=0:6, ordered_result=TRU

Re: [R] Quantiles with ordered categories

2017-03-14 Thread matthias-gondan
with ordered categories Inline. 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, wrote: > Dear

Re: [R] Quantiles with ordered categories

2017-03-14 Thread Bert Gunter
Inline. 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, wrote: > Dear R users, > > This works: > > quantile(1:10, probs=0.5) > >

[R] Quantiles with ordered categories

2017-03-14 Thread matthias-gondan
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 a