[R] median() function on zoo objects

Gabor Grothendieck ggrothendieck at gmail.com
Sat Sep 12 19:40:53 CEST 2009


Can you provide a reproducible example.  See last line to every message
on r-help. When I try it it works:

> median(zoo(1:3))
2
2


On Sat, Sep 12, 2009 at 1:14 PM, Marc Chiarini <marc.chiarini at tufts.edu> wrote:
> Hello R-help community:
>
> I have what I think is a simple question that I hope someone can answer.
>  When using the median() function on any zoo object (in particular, mine is
> an irregular time series), I get the following error, which is thrown from
> .gt():
>
> Error in if (xi == xj) 0L else if (xi > xj) 1L else -1L :
>  argument is of length zero
>
> median() of course works fine on the coredata() of my zoo object, but not on
> the object itself.
>
> Is the median.default function coded incorrectly for zoo objects?  If not,
> then I don't understand why functions like mean() and sd() work correctly on
> the same zoo object, but not median().  Am I asking the right questions?
>  Thanks for any help you can offer.
>
> Regards,
> Marc




More information about the R-help mailing list