Conditional Function in R I have an R function for (i in 1:10) that reads in data and performs some cleaning. Is it possible to write a flexible statement to execute certain parts of the code conditionally, for example have different steps for i = 2 and 8?
You can add conditions inside the loop if you want:

for (i in 1:10){
  if (i&lt;=2){print("1-2")}
  if (i&gt;2){print(" &gt;2")}
}