Can I get.seed() somehow?

If you didn’t keep the seed, there’s no general way to “roll back” the random number generator to a previous state after you’ve observed a random draw. Going forward, what you may want to do is save the value of .Random.seed along with the results of your computations. Something like this.

x <- .Random.seed
result <- <your code goes here>
attr(result, "seed") <- x

Then you can reset the PRNG as follows; result2 should be the same as result.

.Random.seed <- attr(result, "seed")
result2 <- <your code goes here>

Leave a Comment