In R, how can I print a character list 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? e.g.
my_char_list = c(A:Z)
my_char_list = c("A":"Z")
These don't work, I want the output to be: "A" "B" "C" "D"
, or separated by commas.
printf("%c\n", string[n-1]); since you do not want to go out bounds of your array (and cause Undefined Behavior), or print two characters next of the requested character, since when I ask for the 1st character, you should print string[0] , when I ask for the 2nd, you should print string[1] , and so on.
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"
> 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"
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With