[R] how to generate sequence "a" - "z"

Duncan Murdoch murdoch at stats.uwo.ca
Tue Jan 29 16:26:59 CET 2008


On 1/29/2008 7:39 AM, skestin wrote:
> I suppose it's very simple but I can't find the way to generate a sequence of
> characters, e.g. from "a" to "z".
> Could you please help me with this?

If you want the standard collation sequence, use the letters variable, 
as others have said.

If you want the sequence that applies in your locale (where does "ü" 
fall?), it's harder.  I don't know a simple way, but this gives you 
collation order in the German locale in Windows:

 > x <- as.raw(32:255)
 > y <- readChar(x, rep(1, 224))
 > Sys.setlocale("LC_COLLATE", "German")
[1] "German_Germany.1252"
 > sort(y)
   [1] "\177" ""    ""    ""    ""    ""    "'"    "-"    "­"    "–"
  [11] "—"    " "    " "    "!"    "\""   "#"    "$"    "%"    "&"    "("
  [21] ")"    "*"    ","    "."    "/"    ":"    ";"    "?"    "@"    "["
  [31] "\\"   "]"    "^"    "ˆ"    "_"    "`"    "{"    "|"    "}"    "~"
  [41] "¡"    "¦"    "¨"    "¯"    "´"    "¸"    "¿"    "˜"    "‘"    "’"
  [51] "‚"    "“"    "”"    "„"    "‹"    "›"    "+"    "<"    "="    ">"
  [61] "±"    "«"    "»"    "×"    "÷"    "¢"    "£"    "¤"    "¥"    "§"
  [71] "©"    "¬"    "®"    "°"    "µ"    "¶"    "·"    "†"    "‡"    "•"
  [81] "…"    "‰"    "€"    "0"    "¼"    "½"    "¾"    "1"    "¹"    "2"
  [91] "²"    "3"    "³"    "4"    "5"    "6"    "7"    "8"    "9"    "a"
[101] "A"    "ª"    "á"    "Á"    "à"    "À"    "â"    "Â"    "ä"    "Ä"
[111] "ã"    "Ã"    "å"    "Å"    "æ"    "Æ"    "b"    "B"    "c"    "C"
[121] "ç"    "Ç"    "d"    "D"    "ð"    "Ð"    "e"    "E"    "é"    "É"
[131] "è"    "È"    "ê"    "Ê"    "ë"    "Ë"    "f"    "F"    "ƒ"    "g"
[141] "G"    "h"    "H"    "i"    "I"    "í"    "Í"    "ì"    "Ì"    "î"
[151] "Î"    "ï"    "Ï"    "j"    "J"    "k"    "K"    "l"    "L"    "m"
[161] "M"    "n"    "N"    "ñ"    "Ñ"    "o"    "O"    "º"    "ó"    "Ó"
[171] "ò"    "Ò"    "ô"    "Ô"    "ö"    "Ö"    "õ"    "Õ"    "ø"    "Ø"
[181] "œ"    "Œ"    "p"    "P"    "q"    "Q"    "r"    "R"    "s"    "S"
[191] "š"    "Š"    "ß"    "t"    "T"    "þ"    "Þ"    "™"    "u"    "U"
[201] "ú"    "Ú"    "ù"    "Ù"    "û"    "Û"    "ü"    "Ü"    "v"    "V"
[211] "w"    "W"    "x"    "X"    "y"    "Y"    "ý"    "Ý"    "ÿ"    "Ÿ"
[221] "z"    "Z"    "ž"    "Ž"



More information about the R-help mailing list