Control Structures
Control structures allow us to control flow of the program.
If Else
a <- 0
if (a < 1) {
a <- 100
} else {
a <- -100
}
a
[1] 100For loop
numbers <- 1:10
for (i in numbers) {
print (i)
# or
print (numbers[i])
}Nested loops.
While loops
Repeat
Next, break
Last updated
Was this helpful?