> In the help for Extremes ?min
>> Note that all versions fail for raw and complex vectors since these have no ordering.
> This makes sense for complex vectors, yet `raw` vectors seem to have a
> natural order. Indeed:
> which.min(as.raw(c(5L, 2L, 1L, 99L)))
> works and would identify the minimum. Similarly comparison operators
> work on raw vectors (and fail, expectedly, on complex ones).
> Is there something peculiar to min() and friends that make raw vectors
> invalid input?
Please re-read the help for which.min: as it says you computed on an
internal coercion to double. Doubles do have an ordering.
Like factors, raw vectors have numeric codes, but that does not imply
that the ordering of the numeric codes is relevant to the original
object. And reading the help for comparisons would have informed you
Raw vectors should not really be considered to have an order, but
the numeric order of the byte representation is used.
One use case for a raw vector is to store bytes in an unspecified 8-bit
encoding. What ordering would be relevant depends on the encoding -
this is even true for the ASCII subset - some people sort AaBb some
AB...ab and some locales even sort aAbB (although I have never seen that
recommended for human usage).
Brian D. Ripley, [hidden email] Emeritus Professor of Applied Statistics, University of Oxford