R Programming: Extract first 10 english letter in lower case and last 10 letters in upper case and extract letters between 22nd to 24th letters in upper case
R Programming: Basic Exercise-8 with Solution
Write a R program to extract first 10 english letter in lower case and last 10 letters in upper case and extract letters between 22nd to 24th letters in upper case.
Note: Use built-in datasets letters and LETTERS.
Sample Solution :
R Programming Code :
print("First 10 letters in lower case:")
t = head(letters, 10)
print(t)
print("Last 10 letters in upper case:")
t = tail(LETTERS, 10)
print(t)
print("Letters between 22nd to 24th letters in upper case:")
e = tail(LETTERS[22:24])
print(e)
Sample Output:
[1] "First 10 letters in lower case:" [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" [1] "Last 10 letters in upper case:" [1] "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" [1] "Letters between 22nd to 24th letters in upper case:" [1] "V" "W" "X"
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a R program to print the numbers from 1 to 100 and print "Fizz" for multiples of 3, print "Buzz" for multiples of 5, and print "FizzBuzz" for multiples of both.
Next: Write a R program to find the factors of a given number.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics