Any call that uses a random number generator will change the current seed, even if you manually set it using set.seed .
set.seed(1) x <- .Random.seed # get the current seed runif(10) # uses random number generator, so changes current seed y <- .Random.seed identical(x, y) # FALSE
As @StephanKolassa shows, you must reset to use the seed before each use of the random number generator to ensure that it uses the same one every time.
Matthew plourde
source share