title: Why set.seed() affects sample() in R
body: <p>I always thought <code>set.seed()</code> only makes random variable generators (e.g., <code>rnorm</code>) to generate a unique sequence for any specific set of input values.</p>
  <p>However, I'm wondering, why when we set the <code>set.seed()</code>, then the function <code>sample()</code> doesn't do its job correctly?</p>
  <h2>Question</h2>
  <p><strong>Specifically, given the below example,</strong> is there a way I can use <code>set.seed</code> before the <code>rnorm</code> but <code>sample</code> would still produce new random samples from this <code>rnorm</code> if <code>sample</code> is run multiple times?</p>
  <h1>Here is an R code:</h1>
  <pre><code>set.seed(123458)
  x.y = rnorm(1e2)
  
  sampled = sample(x = x.y, size = 20, replace = TRUE)
  
  plot(sampled)
  </code></pre>