I have this loop in R that generates 100 random numbers - I know that this can obviously be done without a loop, but for argument sake, I generated 100 random numbers with a loop:
final_results <- list()
for (i in 1:100)
{
index_i = i
num_i = rnorm(1,1,1)
temp_i = data.frame(index_i,num_i)
final_results[[i]] <- temp_i
}
results_dataframe <- do.call(rbind.data.frame, final_results)
In the end, I use the do.call(rbind.data.frame)
option to convert the list of random numbers into a data frame.
- I was just curious - are there any alternate options for
do.call(rbind.data.frame)
that could have been used instead?
Thank you!