[R] difference in order() between Linux and Windows with mixtures of caps and normal letters

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 25 12:45:53 CEST 2004


This is nothing to do with the type of OS and everything to do with the
locales in use.  It looks like you have the C locale in Linux and an
English-language locale in Windows.  Since you don't tell us where in the
world you are, you most likely are from the country that doesn't know
there are any others.* So I suggest you want

LANG=en_US or
LC_COLLATE=en_US

set as your locale when running R (set in .Renviron, say?)

?Sys.getlocale will give you the full scoop, and ?Comparison explains this
exact issue.

BTW, R 1.6.2 is *really* old and my memory of how things work that far
back is probably imperfect (although by chance it is the earliest version
I have still running).


On Fri, 25 Jun 2004, Joris DeWolf wrote:

> Could anybody explain this difference in the function order() between R 
> under windows and R under Linux ?
> It seems that under Linux the order in of character dsitinguishes 
> between caps and normal letters and sorts them starting with the 
> capitals (see below).
> How can I avoid this (I mean: get the same results as I get under Windows)?
> Thanks
> Joris
> 
> 
> Under Windows R 1.6.2
> 
>  > mstring <- c("b","c","a","t","d")
>  > mstring[order(mstring)]
> [1] "a" "b" "c" "d" "t"
>  > Mstring <- c("b","c","a","T","D")
>  > Mstring[order(Mstring)]
> [1] "a" "b" "c" "D" "T"
> 
> 
> the same under Linux R.1.6.2
> 
>  > mstring <- c("b","c","a","t","d")
>  > mstring[order(mstring)]
> [1] "a" "b" "c" "d" "t"
>  > Mstring <- c("b","c","a","T","D")
>  > Mstring[order(Mstring)]
> [1] "D" "T" "a" "b" "c"


* The `National Science Foundation' sends requests to international
referees with no country identification, not even in the address the
telephone code, the email address ....

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list