title: set.seed in R working different depending on whether it is the first time I opened up R Studio or not.
body: <p>I appreciate your help with this issue. It's quite a simple problem that is driving me nuts.</p>
  
  <p>I have a vector of row numbers and need to randomly select two halves. What I've done is (1) create the vector of row numbers and randomize the order, (2) divide that vector into two halves. My code is below. I have set my seed at the top of my code.</p>
  
  <p>The issue I am running into is that I am getting different vectors of row numbers depending on whether it is the first time I opened R Studio or not. If it's the first time I open R Studio and run the code I get one vector of numbers (the same every time). When I am in R Studio I can rerun my code, clearing my memory every time, and get consistent results. The issue is that the two set of results differ from each other...</p>
  
  <pre><code>d &lt;- read.csv("data.csv")
  
  set.seed(123)
  
  library(mice)
  library(psych)
  library(nFactors)
  library(lavaan)
  
  rowNums &lt;- sample(x = which(d$dataset == "Main"), size = nrow(d[d$dataset =="Main",])) #Vector of randomly arranged row numbers for dataset "Main"
  
  rows.data1 &lt;- head(x = rowNums, n = 344)
  rows.data2 &lt;- tail(x = rowNums, n = 343)
  </code></pre>
  
  <p>Thanks again in advance for your help! </p>