I am running some (big) simulations in R and of course i would like to save the results each time i run them for reproducibility but also for examining the results. Actually, i work in Rmarkdown, but this i think doesn't play a role since it is the same for R scripts in general.
More precisely, i am running a simulation on mixed models and i want to do 2 steps:
- Run 500 simulated datasets, do whatever i want to do with them,
- Re-run exactly the same simulation but with 1000 datasets. BUT, i want the first 500 to be exacly the same as in step 1.
And indeed, by setting the seed i managed to do that! In step 2, the first 500 are identical to the those of step 1.
However, i would expect that in step 2 the required time would be equal to that of step 1. That is, restore the 500 simulated datasets already ran in step 1 and then run another 500. But to my surprise, it took exactly double time to carry out step 2, as it was another 1000 simulated datasets from scratch....
Do you know why does this happen ? Is it normal to re-run the simulations although i have set the seed ? Are they not saved by that way ?
I hope i explain my situaton well! If not, please ask me for further explanation...