[R] How to Arrange character vector in alphabetic order

Jeff Gentry jgentry at jimmy.harvard.edu
Wed Aug 25 21:36:13 CEST 2004


> Is there any function that can arrange a character in alphabetic order? Thanks for answer

Check out sort().

> vv <- c(letters[5:10], letters[20:11], letters[21:26], letters[4:1])
> vv
 [1]
"e" "f" "g" "h" "i" "j" "t" "s" "r" "q" "p" "o" "n" "m" "l" "k" "u" "v" "w"[20]
"x" "y" "z" "d" "c" "b" "a"
> sort(vv)
 [1]
"a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"[20]
"t" "u" "v" "w" "x" "y" "z"




More information about the R-help mailing list