[Rd] WISH: set.seed(seed) to produce error if length(seed) != 1 (now silent)

Henrik Bengtsson henr|k@bengt@@on @end|ng |rom gm@||@com
Fri Sep 17 10:47:48 CEST 2021


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



More information about the R-devel mailing list