Closed SarahBauduin closed 8 years ago
see ?set.seed.
You can save the state of a seed and re-introduce it later. This would be used for "with-local-randomness":
oldSeed <- .Random.seed
#do some stuff which will continue with the seed as per normal
set.seed(oldSeed)
# returns to sequence as if nothing had occurred
For a "new seed", you remove the old one and R will automatically select a random new one:
rm(.Random.seed)
if using Plot
, there is clickExtent
. It is not the same as what is required for setting the visual pixel size and having the window adjust automatically to maintain the visual pixel size.
It wouldn't be impossible to implement, as Plot
already uses several calculations to adjust plotting device to window size, so it would just be the inverse calculation. But, not a high priority, I don't think.
Thanks! I updated the dictionary for new-seed and with-local-randomness. I put "not implemented" for set-patch-size as clickExtent is not doing the same. It doesn't really matter that there is no equivalent, it's among all the plot functions from NetLogo that are "not implemented" because they are too specific to the NetLogo visuals.
@eliotmcintire @SarahBauduin note that storing the seed is not enough to later re-create the RNG state. you also need to save the kind og RNG being used:
oldSeed <- get(".Random.seed", envir = .GlobalEnv)
oldRNGkind <- RNGkind()
to load the RNG state afterward:
do.call("RNGkind", as.list(oldRNGkind))
assign(".Random.seed", oldSeed, envir = .GlobalEnv)
Thanks @achubaty I updated the dictionary with your solution
set.seed()
?