On Fri, 17 Oct 2003 11:58:49 +0200, Uwe Ligges <[EMAIL PROTECTED] dortmund.de> wrote:

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


Thanks for the help, it worked great. However, it appers that using the Sys.setlocale("LC_COLLATE", "C") makes R sort the vector in a new way, different from the two mentioned above. But since R sorts character vectors at same manner on both W2K and Window NT, after writing Sys.setlocale("LC_COLLATE", "C"), it is sufficient for me.


Ivar Herfindal


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




______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help




______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to