Inspired by LucyStat's tweet about set.seed and library(ggplot2) I wrote this example
set.seed(42)
runif(1)
set.seed(42)
1+1
runif(1)
set.seed(42)
library("ggplot2")
runif(1)
in which the third call to runif gives a different number than the first two, which was expected. This only works in a new session. I wanted to illustrate it using reprex::reprex() but here is the output.
set.seed(42)
runif(1)
#> [1] 0.914806
set.seed(42)
1+1
#> [1] 2
runif(1)
#> [1] 0.914806
set.seed(42)
library("ggplot2")
runif(1)
#> [1] 0.914806
Am I doing something wrong?