for (i in seq(1,10)){
if (i < 5){
print(paste(i, "is less than 5."))
} else if (i > 5){
print(paste(i, "is greater than 5."))
} else{
print(paste(i, "is equal to 5."))
}
}
Rscript if.R
[1] "1 is less than 5."
[1] "2 is less than 5."
[1] "3 is less than 5."
[1] "4 is less than 5."
[1] "5 is equal to 5."
[1] "6 is greater than 5."
[1] "7 is greater than 5."
[1] "8 is greater than 5."
[1] "9 is greater than 5."
[1] "10 is greater than 5."