robjhyndman/forecast

Preserve state of random number generator in .onAttach()

Closed this issue · 1 comments

Currently .onAttach() will change the state of a users random number generator:

forecast/R/attach.R

Lines 1 to 2 in d143826

.onAttach <- function(...) {
if (!interactive() || stats::runif(1) > 0.2) return()

Not a bug per se but would you consider a change to preserve it?

For reference I believe {ggplot2} was updated to use withr::with_preserve_seed() for this reason.

Motivate by this thread https://fosstodon.org/@henrikbengtsson@mastodon.social/112079393660379008

Thanks for the suggestion, I've created a PR (#955) for this.