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
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
> 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 <-
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
> 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
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
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
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