From proebuck at mdanderson.org  Wed Dec  7 19:29:26 2011
From: proebuck at mdanderson.org (Roebuck,Paul L)
Date: Wed, 7 Dec 2011 12:29:26 -0600
Subject: [Rd] bug in rank(), order(), is.unsorted() on character vector
In-Reply-To: <4EDF34D8.40001@fhcrc.org>
Message-ID: <CB050CA6.25561%proebuck@mdanderson.org>

Do this first and try again.

R> Sys.setlocale("LC_COLLATE", "C")


On 12/7/11 3:41 AM, "Herv? Pag?s" <hpages at fhcrc.org> wrote:

> Hi,
> 
> This looks OK:
> 
>> x <- c("_1_", "1_9", "2_9")
>> rank(x)
> [1] 1 2 3
> 
> But this does not:
> 
>> xa <- paste(x, "a", sep="")
>> xa
> [1] "_1_a" "1_9a" "2_9a"
>> rank(xa)
> [1] 2 1 3
> 
> Cheers,
> H.
> 
>> sessionInfo()
> R version 2.14.0 (2011-10-31)
> Platform: x86_64-unknown-linux-gnu (64-bit)
> 
> locale:
>   [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C
>   [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8
>   [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8
>   [7] LC_PAPER=C                 LC_NAME=C
>   [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> loaded via a namespace (and not attached):
> [1] tools_2.14.0
> 



[Rd] bug in rank(), order(), is.unsorted() on character vector
Roebuck,Paul L