[R] Sorting strings

Keith Jewell k.jewell at campden.co.uk
Mon Feb 20 12:24:13 CET 2012


"Petr Savicky" <savicky at cs.cas.cz> wrote in message 
news:20120220105153.GC21422 at cs.cas.cz...
> On Mon, Feb 20, 2012 at 02:18:42AM -0800, statquant2 wrote:
>> Hi all, I am having difficulties to understand how R sort strings:
>>
>> If I do
>> R) sort(c("X.","X0B"))
>> [1] "X."  "X0B"
>>
>> So for me, as far as lexicographic order is concerned I can add whatever 
>> to
>> the end, the order will remain the same, but :
>
> Hi.
>
> This neednot be true for strings of different length.
> For example
>
>  ab
>  abc
>
> become by concatenation with z
>
>  abcz
>  abz
>
> Petr Savicky.
>

That's not the explanation in this case.

The OP isn't telling us everything.
I get [R version 2.14.1 Platform: i386-pc-mingw32/i386 (32-bit)]:
> sort(c("X.","X0B"))
[1] "X."  "X0B"
> sort(c("X.Z","X0B.Z"))
[1] "X.Z"   "X0B.Z"

KJ



More information about the R-help mailing list