On 25/05/2011 6:06 AM, Niklaus Kuehnis wrote:
What's the logic behind the following, and where can I find any
documentation about it? In particular, why are 2:9 - as characters - not
regarded as being smaller than 10?
# R-Code:
a<- as.character(1:12)
a< 10
# [1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE
See ?Comparison for help. There are lots of details given there.
In summary: your second comparison is of "2" to "10". Since the
character "2" sorts later than the character "1", "2" < "10" is FALSE.
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list
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.