Reputation: 209
I am using Rstudio and I created a random data like this:
n<-500
u<-runif(n)
This data is now stored but obviously once I run the code again it will change. How could I store it to use it again? If the number of points was small I would just define a vector and manually write the numbers like
DATA<-c(1,2,3,4)
But obviously doing this for 500 points is not very practical. Thank you.
Upvotes: 3
Views: 1010
Reputation: 318
In such cases, i.e. when using pseudo random number generators, a common approach is to set the seed:
set.seed(12345)
You have to store the seed that you used for the simulation, so that in future you's set the same seed and get the same sequence of numbers. The seed indicates that the numbers are not truly random, they're pesudo random. The same seed will generate the same numbers. There are services such as RANDOM which attempt to generate true random numbers.
Upvotes: 5