[R] sort charcters in W2K and NT

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Oct 17 11:58:49 CEST 2003


Ivar Herfindal wrote:

> Hello.
> 
> I have a problem using sort() in windows 2000 and windows NT 4.0, 
> running R 1.8.0 on both. I want to sort a vector of characters names, 
> where I have used "Scandinavian" letters, like 'Æ', 'Ø', and 'Å' (for 
> those who cannot display these letters this question seems rather 
> meaningless, i guess). Windows 2000 sorts the vector like I am used to 
> from other software, with 'Å' as the last letter in the alphabet, while 
> windows NT has "Å" just after "A", and "Ø" following "O".
> 
> Is there a way to solve this problem (other than replace the 
> Scandinavian letters)?
> 
> A short example:
> sort(c('a','p','å'))
> # on windows 2000:
> [1] "a" "p" "å"
> 
> # on windows NT
> [1] "a" "å" "p"
> 
> Thanks in advance

?sort tells us:

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

and ?Comparison points you to ?locales which gives an example:

   Sys.setlocale("LC_COLLATE", "C")  # turn off locale-specific sorting

Uwe Ligges


> Ivar Herfindal
> 
> On windows 2000:
> 
>> version
> 
>         _              platform i386-pc-mingw32
> arch     i386           os       mingw32        system   i386, mingw32  
> status                  major    1              minor    8.0            
> year     2003           month    10             day      08             
> language R
> 
>>
> 
> On windows NT:
> 
>> version
> 
>         _              platform i386-pc-mingw32
> arch     i386           os       mingw32        system   i386, mingw32  
> status                  major    1              minor    8.0            
> year     2003           month    10             day      08             
> language R
> 
>>
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list