[R] Does order() behave differently on different platforms?

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Aug 15 19:56:02 CEST 2003


Raja Surapanani wrote:
> Hello, 
> 
> I am running R 1.7.1 on two platforms and it seems to me that order() behaves 
> differently on them. I noticed this when a test case passed in linux but 
> failed on solaris. This is the behavior on the solaris platform: 
> 
> R.Version()
> $platform
> [1] "sparc-sun-solaris2.8"

[SNIP]

>>x <- c("a", "b", "c", "(d")
>>sort(x)
> 
> [1] "(d" "a"  "b"  "c" 
> 
> This is the behavior on the linux platform: 
> 
> 
>>R.Version()
> 
> $platform
> [1] "i686-pc-linux-gnu"

[SNIP]

>>sort(x)
> 
> [1] "a"  "b"  "c"  "(d"
> 
> Am I missing something here or is there really a difference in the way order() 
> works on different platforms? Thanks for your help. 

You missed to read the help page. ?sort tells us:

"The sort order for character vectors will depend on the collating 
sequence of the locale in use: see Comparison."

Please follow that reference and read ?Comparison as well.

Uwe Ligges




More information about the R-help mailing list