Introduction
A for loop helps you repeat a set of actions many times without writing the same code again and again.
for (variable in sequence) { # code to repeat }
for (i in 1:5) { print(i) }
for (letter in c('a', 'b', 'c')) { print(letter) }
for (num in seq(2, 10, by=2)) { print(num) }
numbers <- 1:4 for (n in numbers) { square <- n^2 print(paste(n, "squared is", square)) }
for loop do in R programming?for (i in 1:3) {
print(i * 2)
}for i in 1:4 {
print(i)
}Pass the test and this pattern moves unknown