[Rd] WISH: set.seed(seed) to produce error if length(seed) != 1 (now silent)
Avraham Adler
@vr@h@m@@d|er @end|ng |rom gm@||@com
Fri Sep 17 12:06:44 CEST 2021
Hi, Henrik.
I’m curious, other than proper programming practice, why?
Avi
On Fri, Sep 17, 2021 at 11:48 AM Henrik Bengtsson <
henrik.bengtsson using gmail.com> wrote:
> Hi,
>
> according to help("set.seed"), argument 'seed' to set.seed() should be:
>
> a single value, interpreted as an integer, or NULL (see ‘Details’).
>
> From code inspection (src/main/RNG.c) and testing, it turns out that
> if you pass a 'seed' with length greater than one, it silently uses
> seed[1], e.g.
>
> > set.seed(1); sum(.Random.seed)
> [1] 4070365163
> > set.seed(1:3); sum(.Random.seed)
> [1] 4070365163
> > set.seed(1:100); sum(.Random.seed)
> [1] 4070365163
>
> I'd like to suggest that set.seed() produces an error if length(seed)
> > 1. As a reference, for length(seed) == 0, we get:
>
> > set.seed(integer(0))
> Error in set.seed(integer(0)) : supplied seed is not a valid integer
>
> /Henrik
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Sent from Gmail Mobile
[[alternative HTML version deleted]]
More information about the R-devel
mailing list