Subsequence letters using range operation

We can get the subsequence of letters using the index. Index starts with 1 and ends with 26 (since there are 26 letters from a to z). We are getting from letters/LETTERS function.

Syntax:

letters[start:end]

LETTERS[start:end]

Where, start is the starting letter index and end is the ending letter index.

Example: R program to get subsequence letters using index

R




# return all upper case letters from 
# index 1 to index 12
print(LETTERS[1:12])
  
# return all lower case letters from
# index 1 to index 12
print(letters[1:12])
  
# return all upper case letters from
# index 5 to index 26
print(LETTERS[5:26])
  
# return all lower case letters from
# index 5 to index 26
print(letters[5:26])


Output:

[1] β€œA” β€œB” β€œC” β€œD” β€œE” β€œF” β€œG” β€œH” β€œI” β€œJ” β€œK” β€œL”

[1] β€œa” β€œb” β€œc” β€œd” β€œe” β€œf” β€œg” β€œh” β€œi” β€œj” β€œk” β€œl”

[1] β€œE” β€œF” β€œG” β€œH” β€œI” β€œJ” β€œK” β€œL” β€œM” β€œN” β€œO” β€œP” β€œQ” β€œR” β€œS” β€œT” β€œU” β€œV” β€œW” β€œX” β€œY” β€œZ”

[1] β€œe” β€œf” β€œg” β€œh” β€œi” β€œj” β€œk” β€œl” β€œm” β€œn” β€œo” β€œp” β€œq” β€œr” β€œs” β€œt” β€œu” β€œv” β€œw” β€œx” β€œy” β€œz”

Sequence of Alphabetical Character Letters from A-Z in R

In this article, we are going to discuss how to get a sequence of character letters from A-Z in R programming language.

Similar Reads

Return all lower case letters using letters function

We will get all letters in lowercase sequence by using the letters function...

Return all upper case letters using LETTERS function

...

Subsequence letters using range operation

We will get all letters in uppercase sequence by using LETTERS function....

Random sequence of letters using sample() function

...

Contact Us