Message-ID: <49B6E94F.10802@idi.ntnu.no>
Date: 2009-03-10T22:27:27Z
From: Wacek Kusnierczyk
Subject: puzzled by math on date-time objects
In-Reply-To: <8b356f880903101457g4503cdfakccce5032ec5df49d@mail.gmail.com>
Stavros Macrakis wrote:
> It does seem sensible that median and quantile would work for the
> POSIXct, Date, and other classes for which they are logically
> well-defined, but strangely enough, they do not (except for odd-length
> input). The summary function has a special case (summary.POSIXct)
> which does the straightforward, obvious thing here. I do not
> understand why this is not done by median and quantile themselves.
>
> Conversely, for the complex class, median and quantile do not give an
> error but instead produce meaningless results
>
median, but not quantile, seems to fail on complex:
median(0i)
# error, needs numeric
quantile(0i)
# fine
the latter is a presumably a bug, because it doesn't follow the
documentation, ?quantile:
"
quantile(x, ...)
Arguments:
x: numeric vectors whose sample quantiles are wanted. Missing
values are ignored.
"
and complex is not numeric:
is.numeric(0i)
# FALSE
> since the complexes do
> not form an ordered field).
well, in r complexes are not comparable, but they can be sorted:
0i < 1i
# no go
sort(c(0i, 1i))
# fine
vQ