Consider the following:

x <- letters[1:5]
x < 0

This gives

[1] FALSE FALSE FALSE FALSE FALSE

which kind of makes sense, I guess, though I would a priori have expected all NAs.

But then do:

x[3] <- "*"
x < 0

This gives

[1] FALSE FALSE  TRUE FALSE FALSE

which puzzles me.  Why is "*" considered to be less than 0?

At one point I made the conjecture that it had something to do with the ordering of ASCII characters, but it does not seem to. A little more investigation led me to conjecture that all ASCII characters except real-live letters and numerals come out as being less than 0.

Can anyone explain the rationale to me? Not that it matters a damn. Just idle curiosity.

cheers,

Rolf Turner

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to