Exercises 1 - Loops Solutions

Files Corresponding to Short Course Programming in R

Exercises 1 - Loops Solutions

(letter) is the (nth) letter of the alphabet.

at each iteration.

For example,
print(paste(letters[1], "is the", scales::ordinal(1), "letter of the alphabet."))

for(i in 1:26){
  print(paste(letters[i], "is the", scales::ordinal(i) ,"letter of the alphabet."))
}
## [1] "a is the 1st letter of the alphabet."
## [1] "b is the 2nd letter of the alphabet."
## [1] "c is the 3rd letter of the alphabet."
## [1] "d is the 4th letter of the alphabet."
## [1] "e is the 5th letter of the alphabet."
## [1] "f is the 6th letter of the alphabet."
## [1] "g is the 7th letter of the alphabet."
## [1] "h is the 8th letter of the alphabet."
## [1] "i is the 9th letter of the alphabet."
## [1] "j is the 10th letter of the alphabet."
## [1] "k is the 11th letter of the alphabet."
## [1] "l is the 12th letter of the alphabet."
## [1] "m is the 13th letter of the alphabet."
## [1] "n is the 14th letter of the alphabet."
## [1] "o is the 15th letter of the alphabet."
## [1] "p is the 16th letter of the alphabet."
## [1] "q is the 17th letter of the alphabet."
## [1] "r is the 18th letter of the alphabet."
## [1] "s is the 19th letter of the alphabet."
## [1] "t is the 20th letter of the alphabet."
## [1] "u is the 21st letter of the alphabet."
## [1] "v is the 22nd letter of the alphabet."
## [1] "w is the 23rd letter of the alphabet."
## [1] "x is the 24th letter of the alphabet."
## [1] "y is the 25th letter of the alphabet."
## [1] "z is the 26th letter of the alphabet."