Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store random data created in r for further use?

Tags:

r

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.

like image 292
Scavenger23 Avatar asked Jan 20 '26 03:01

Scavenger23


1 Answers

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.

like image 108
Aksakal almost surely binary Avatar answered Jan 21 '26 17:01

Aksakal almost surely binary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!