The set.seed
function is used to set the random seed for all randomization functions. If you are using R to create a randomization that you want to be able to reproduce, you should use set.seed
first.
set.seed(1643)
samp1 <- sample(x = 1:5,size = 200,replace = TRUE)
set.seed(1643)
samp2 <- sample(x = 1:5,size = 200,replace = TRUE)
> identical(x = samp1,y = samp2)
[1] TRUE
Note that parallel processing requires special treatment of the random seed, described more elsewhere.