Skip to content
Prev 388805 / 398502 Next

Getting different results with set.seed()

What you could also try is check if the self coded functions use the 
random generator when defining them:

starting_seed <- .Random.seed

Step 1. Self-coded functions (these functions generate random numbers as 
well)

# check if functions have modified the seed:
all.equal(starting_seed, .Random.seed)

Step 2: set.seed (123)



What has also happened to me is that some of the functions I called had 
their own random number generator independent of that of R. For example 
using one in C/C++.

Do your functions do stuff in parallel? For example using the parallel 
or snow package? In that case you also have to set the seed in the 
parallel workers.

Best,
Jan
On 19-08-2021 11:25, PIKAL Petr wrote: