R

Control Statement

for

for (i in 1:4) {
    print(i)
}

while

a <- 10
while (a > 4) {
    cat(a, "...", sep = " ")
    a <- a - 1
}
Warning

Keep in mind that for and while loops run slowly in R.
Operations on entire vectors (i.e. a whole row, a whole column)
or apply()-type functions are preferred

if/else

if (4 > 3) {
    print("4 is greater than 3")
} else if (4 == 3) {
    print("4 is equal to 3")
} else {
    print("4 is less than 3")
}
Creative Commons License by zcysxy