[R] Sorting strings

Enrico Schumann enricoschumann at yahoo.de
Mon Feb 20 13:52:55 CET 2012


See ?Comparison, which holds some warnings about what to expect when 
sorting strings.


Am 20.02.2012 11:51, schrieb Petr Savicky:
> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net/



More information about the R-help mailing list