Allocating loops to variables name

See the FAQ: How to do a minimal reproducible example reprex for beginners. This kind of problem without representative data makes it difficult to give very specific suggestions.

In general, while it's possible to do this in R, anyone who has an imperative/ procedural programming language such as C, C++ or Python should script this outside R to generate a cut and paste script.

I just finished banging my head on the R logic before turning to Python. This snippet will give you a flavor in a case where I needed to loop over one object and use the index to take values from two objects.

def use_py():
  Vars = ["DO","pH","Temperature","Turbidity","ORP","Ammonium","Nitrates","BGA","Chlorophyll"]
  part1 = "multcompBoxplot("
  part2 = "~ Month, data=bpdata[,c(1,"
  part3 = ")])"
  for i in range(0,9): print(part1,Vars[i],part2,i+2,part3)

multcompBoxplot(DO ~ Month, data = bpdata[, c(1, 2)])
multcompBoxplot(pH ~ Month, data = bpdata[, c(1, 3)])
multcompBoxplot(Temperature ~ Month, data = bpdata[, c(1, 4)])
multcompBoxplot(Turbidity ~ Month, data = bpdata[, c(1, 5)])
multcompBoxplot(ORP ~ Month, data = bpdata[, c(1, 6)])
multcompBoxplot(Ammonium ~ Month, data = bpdata[, c(1, 7)])
multcompBoxplot(Nitrates ~ Month, data = bpdata[, c(1, 8)])
multcompBoxplot(BGA ~ Month, data = bpdata[, c(1, 9)])
multcompBoxplot(Chlorophyll ~ Month, data = bpdata[, c(1, 10)])

For the OP snip, be aware that nothing defined in the function environment, except possibly the last iteration, is going to escape into the global environment unless you initialize a collector object outside the function and increment it within the loop. See help(for), which has some admonitions about this.