library(batch) Allk<-c(80000) seed = 200 for(j in 1:length(Allk)){ for(i in 1:100) { seed <- rbatch("IBD_NR_19_batch.r",seed=seed,mig=Allk[j]) # add whatever other arguments you want to pass to the AveRes.R function inside the rbatch command } } ~ ~