[R] Correctly Setting New Seed
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Wed May 8 20:35:22 CEST 2013
"Crashes" is not a clear description. When I execute the statement:
set.seed(seed)
I get the error
Error in set.seed(seed) : object 'seed' not found
which makes sense because there is no variable defined that is called "seed".
Choose a literal value like 42:
set.seed(42)
or define the variable
seed <- 42
set.seed(seed)
and you should not get that error.
If you get a different error message, then give us a better clue how to reproduce it. (Also, please post plain text email as the Posting Guide requests. You have read that, right?)
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
"Ellerbe, Caitlyn Nicole" <ellerbcn at musc.edu> wrote:
>Could someone please suggest a method to store the current random seed.
>I'm having trouble understanding how to correctly use set.seed and
>.Random.seed.
>
>Specifically, I have the following code that crashes:
>
>
>
>set.seed(seed)
>
>for(i in 1:10){
>
> print( runif(1))
>
>}
>
>
>
>To get around this I need to split the number of iterations into
>chunks:
>
>
>
>set.seed(seed)
>
>for(i in 1:5){
>
>print(runif(1))
>
>new.seed<-.Random.seed
>
>}
>
>
>
>set.seed(new.seed)
>
>for(i in 6:10){
>
>print(runif(1))
>
>}
>
>
>
>When I compare the sequence of numbers from the single run to the
>sequence from the chunked code they don't match. Is the .Random.seed
>argument in the wrong position or is there another way to accomplish
>this?
>
>-------------------------------------------------------
>Caitlyn Ellerbe
>
>Division of Biostatistics
>Department of Public Health
>Medical University of South Carolina
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list