Hi,
Found in the man page for max(), min(), pmax(), pmin(), etc...:
(Note that all versions fail for raw and complex vectors since
these have no ordering.)
It seems that raw vectors *do* have an ordering (why wouldn't they?):
> x <- as.raw(0:8)
> x
[1] 00 01 02 03 04 05 06 07 08
> x < x[5]
[1] TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
and also:
> which.max(x)
[1] 9
> which.min(x)
[1] 1
This is the R 3.0 series and current R devel.
If for whatever reason max(), min(), pmax(), pmin(), etc... cannot
be made to work on raw vectors, it would be nice to see the man page
modified to say just something like "raw vectors are not supported".
Also there is no reason why order(), sort(), rank(), etc... couldn't
work on raw vectors.
Another inconsistency of the same kind is that character vectors
also have an ordering but which.min() and which.max() don't work
properly on them:
> y <- sample(letters)
> max(y)
[1] "z"
> which.max(y)
integer(0)
Warning message:
In which.max(y) : NAs introduced by coercion
It seems that some of these inconsistencies could be avoided by having
all these functions and operators share more code internally.
Cheers,
H.
--
Herv? Pag?s
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpages at fhcrc.org
Phone: (206) 667-5791
Fax: (206) 667-1319