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

2021-09-17 Thread Jake Elmstedt
What about splitting the baby and having set.seed(1:2), set.seed(6.1), etc. issue a warning rather than throw an error? It informs the user that their expectations have deviated from reality, encourages proper programming practices, and carries substantially lower risk of breaking things than an e

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

2021-09-17 Thread Avi Gross via R-devel
R wobbles a bit as there is no normal datatype that is a singleton variable. Saying x <- 5 just creates a vector of current length 1. It is perfectly legal to then write x [2] <- 6 and so on. The vector lengthens. You can truncate it back to 1, if you wish: length(x) <- 1 So the question here

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

2021-09-17 Thread Henrik Bengtsson
> I'd say a more serious problem would be using set.seed(.Random.seed) ... Exactly, I'm pretty sure I also tried that at some point. This leads to another thing I wanted to get to, which is to add support for exactly that case. So, instead of having poke around with: globalenv()$.Random.seed <-

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

2021-09-17 Thread Duncan Murdoch
I'd say a more serious problem would be using set.seed(.Random.seed), because the first entry codes for RNGkind, it hardly varies at all. So this sequence could really mislead someone: > set.seed(.Random.seed) > sum(.Random.seed) [1] 24428993419 # Use it to get a new .Random.seed value: > run

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

2021-09-17 Thread Henrik Bengtsson
> I’m curious, other than proper programming practice, why? Life's too short for troubleshooting silent mistakes - mine or others. While at it, searching the interwebs for use of set.seed(), gives mistakes/misunderstandings like using set.seed(), e.g. > set.seed(6.1); sum(.Random.seed) [1] 73930

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

2021-09-17 Thread GILLIBERT, Andre
Hello, A vector with a length >= 2 to set.seed would probably be a bug. An error message will help the user to fix his R code. The bug may be accidental or due to bad understanding of the set.seed function. For instance, a user may think that the whole state of the PRNG can be passed to set.see

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

2021-09-17 Thread Avraham Adler
Hi, Henrik. I’m curious, other than proper programming practice, why? Avi On Fri, Sep 17, 2021 at 11:48 AM Henrik Bengtsson < henrik.bengts...@gmail.com> wrote: > Hi, > > according to help("set.seed"), argument 'seed' to set.seed() should be: > > a single value, interpreted as an integer, or

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

2021-09-17 Thread Henrik Bengtsson
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