[R] Sorting strings

Petr Savicky savicky at cs.cas.cz
Mon Feb 20 11:51:53 CET 2012


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.



More information about the R-help mailing list