For Loop In R | R For Loop - r - learn r - r programming
- In R programming, a for loop is used to iterate over a vectors.
- A for loop is a repetition control structure that permits to efficiently write a loop that wants to execute an exact number of times.
- Vector and Value can take on each of its value during the loop. In each iteration and statement is evaluated.
- x is specifying to string variable. Here x has 10 elements, the LETTERS is composed of a sequence of the characters 1 through 10 (1:10).
- In each iteration, val takes on the value of corresponding element of x.
- Here print() is used to print the value, that value stored in xvariable.
- Here in this output we display the Letters from 1 to 10 “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, which specifies to the loop iterates 10 times as the vector x has 1 through 10 elements.