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

From: Barry Rowlingson <>
Date: Tue, 29 Jan 2008 14:06:38 +0000

Bernd Weiss wrote:
> Hash: SHA1
> skestin schrieb:
> | 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?
> ?letters
> letters

  "letters" is okay for just that sequence, or parts of it, but might not be general enough for the original poster...

  I just discovered 'charToInt' and 'intToChar' in the R.oo package:

  > intToChar(65:68)
  [1] "A" "B" "C" "D"

  Then you can define cseq:

  > cseq =

  and do:
  > cseq('A','G')
   [1] "A" "B" "C" "D" "E" "F" "G"
  > cseq('A','G',2)
   [1] "A" "C" "E" "G"
  > cseq('a','A',-2)
   [1] "a" "_" "]" "[" "Y" "W" "U" "S" "Q" "O" "M" "K" "I" "G" "E" "C" "A"

  Note this uses ASCII codes and not whatever your language alphabet is.

  I'd overload ':' for this and then you could do 'a':'z', but ':' heads into .Primitive territory...

Barry mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 29 Jan 2008 - 16:18:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Jan 2008 - 17:30:08 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive