How to print a list of characters from A to Z?

In R, how can I print a list of characters from A to Z? With integers, I can say:

my_list = c(1:10) > my_list [1] 1 2 3 4 5 6 7 8 9 10 

But can I do the same with characters? eg

 my_char_list = c(A:Z) my_char_list = c("A":"Z") 

They do not work, I want the result to be: "A" "B" "C" "D" or separated by commas.

+5
source share
4 answers
 LETTERS "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" 
+17
source
 > LETTERS [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" [25] "Y" "Z" > letters [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" [25] "y" "z" > LETTERS[5:10] [1] "E" "F" "G" "H" "I" "J" > 
+12
source
 strsplit(intToUtf8(c(97:122)),"") 

for a, b, c, ..., g

 strsplit(intToUtf8(c(65:90)),"") 

for A, B, C, ..., Z

0
source
 #' range_ltrs() returns a vector of letters #' #' range_ltrs() returns a vector of letters, #' starting with arg start and ending with arg stop. #' Start and stop must be the same case. #' If start is after stop, then a "backwards" vector is returned. #' #' @param start an upper or lowercase letter. #' @param stop an upper or lowercase letter. #' #' @examples #' > range_ltrs(start = 'A', stop = 'D') #' [1] "A" "B" "C" "D" #' #' If start is after stop, then a "backwards" vector is returned. #' > range_ltrs('d', 'a') #' [1] "d" "c" "b" "a" range_ltrs <- function (start, stop) { is_start_upper <- toupper(start) == start is_stop_upper <- toupper(stop) == stop if (is_start_upper) stopifnot(is_stop_upper) if (is_stop_upper) stopifnot(is_start_upper) ltrs <- if (is_start_upper) LETTERS else letters start_i <- which(ltrs == start) stop_i <- which(ltrs == stop) ltrs[start_i:stop_i] } 
0
source

Source: https://habr.com/ru/post/1304295/


All Articles