From nilsson.henric at gmail.com  Tue Feb  7 13:37:42 2017
From: nilsson.henric at gmail.com (Henric Winell)
Date: Tue, 7 Feb 2017 13:37:42 +0100
Subject: [Rd] package load altering RNG state
In-Reply-To: <54995b10-e094-1f26-6a18-a52d692d6404@gmail.com>
References: <54995b10-e094-1f26-6a18-a52d692d6404@gmail.com>
Message-ID: <2f43985c-35dd-f505-da37-22aa92ca8be8@gmail.com>

Hi,

On 2017-02-07 13:12, Benjamin Tyner wrote:

> Hello
> 
> When loading a package, I'm wondering if it's frowned upon for the 
> package to alter the state of the random number generator? I guess not, 
> since the parallel package does it?

Surprisingly it is not frowned upon, but it *is* a nuisance.  I brought 
it up a couple of years ago

http://r.789695.n4.nabble.com/parallel-package-changes-Random-seed-td4686321.html

along with a patch, but was told off...

> 
>     > set.seed(6860)
>     > old.seed <- .GlobalEnv$.Random.seed
>     > library(parallel)
>     > new.seed <- .GlobalEnv$.Random.seed
>     > identical(old.seed, new.seed)
>     [1] FALSE
> 
> I ask because, I found myself writing a custom wrapper around library() 
> to restore the original RNG state, in order to increase reproducibility. 
> But now wondering if others would welcome such a feature to be added to 
> base R? Either something very general like
> 
>     preserveRNGstate(library(parallel))
> 
> or perhaps an specific enhancement to library itself?

I would very much welcome a change, but in the light of things it 
doesn't seem likely.

Henric Winell


> 
> Regards
> Ben
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] package load altering RNG state
Henric Winell