I\'m trying to write from a loop to a data frame in R, for example a loop like this>
for (i in 1:20) {
print(c(i+i,i*i,i/1))}
and to write
For loops have side-effects, so the usual way of doing this is to create an empty dataframe before the loop and then add to it on each iteration. You can instantiate it to the correct size and then assign your values to the i'th row on each iteration, or else add to it and reassign the whole thing using rbind().
The former approach will have better performance for large datasets.