title: How do I stop set.seed() after a specific line of code?
body: <p>I would like to end the scope of set.seed() after a specific line in order to have real randomization for the rest of the code. Here is an example in which I want set.seed() to work for "rnorm" (line 4), but not for "nrow" (line 9) </p>
  
  <pre><code>set.seed(2014)
  f&lt;-function(x){0.5*x+2}
  datax&lt;-1:100
  datay&lt;-f(datax)+rnorm(100,0,5)
  daten&lt;-data.frame(datax,datay)
  model&lt;-lm(datay~datax)
  plot(datax,datay)
  abline(model)
  a&lt;-daten[sample(nrow(daten),20),]
  points(a,col="red",pch=16)
  modela&lt;-lm(a$datay~a$datax)
  abline(modela, col="red")
  </code></pre>
  
  <p>Thanks for suggestions, indeed!</p>