title: How is .Random.seed initially created?
body: <p>I'm aware that it's possible to set the seed by using <code>set.seed</code>, but restarting an R session gives a new seed every time. According the <a href="https://stat.ethz.ch/R-manual/R-patched/library/base/html/Random.html" rel="nofollow">R Documentation</a>:</p>
  
  <blockquote>
    <p>Initially, there is no seed; a new one is created from the current time and the process ID when one is required. Hence different sessions will give different simulation results, by default.</p>
  </blockquote>
  
  <p>I looked through the <a href="https://cran.r-project.org/doc/manuals/r-release/R-ints.html#Global-environment" rel="nofollow">R Internals</a> guide, but it only describes what <code>.Random.seed</code> is, rather than how it is initially created.</p>
  
  <p>How does R create the seed at the beginning of a session?</p>
  
  <p>EDIT: Thanks to @sascha's suggestions, I found where the current time and PID are combined. There's a <a href="https://github.com/wch/r-source/blob/4d6982a64955659a9bdc64e4873c09d99ffc4e3c/src/main/times.c#L149" rel="nofollow">function called TimeToSeed</a> which combines the PID and time into a single integer. It looks quite simple, but I'm not well-versed enough in C to understand it.</p>