Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a sequence of characters from 'A'-'Z'

I can make a sequence of numbers like this:

s = seq(from=1, to=10, by=1) 

How do I make a sequence of characters from A-Z? This doesn't work:

seq(from=1, to=10) 
like image 636
James Thompson Avatar asked Dec 06 '10 19:12

James Thompson


People also ask

What is a sequence of character?

A CharSequence is a readable sequence of char values. This interface provides uniform, read-only access to many different kinds of char sequences. A char value represents a character in the Basic Multilingual Plane (BMP) or a surrogate. Refer to Unicode Character Representation for details.


2 Answers

Use LETTERS and letters (for uppercase and lowercase respectively).

like image 162
Shane Avatar answered Oct 14 '22 17:10

Shane


Use the code you have with letters and/or LETTERS:

> LETTERS[seq( from = 1, to = 10 )]  [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" > letters[seq( from = 1, to = 10 )]  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" 
like image 22
Joshua Ulrich Avatar answered Oct 14 '22 17:10

Joshua Ulrich