title: R Sample selection basic question with nrow
body: <p>I follow one tutorial to split ds into several with <code>sample</code> and it works fine. I just can't sleep without  understaning what is going on behind the scene with <code>ind</code> dataset like in sample below, does it know/remember about <code>mtcars</code> somehow, it's just single column integer.  I indicated in comment what I'm trying to get, how R knows which row in dataset marked 1 or 2 ??</p>
  
  <p>Yes I did my Hwork on basic syntax but this probably is too simple)</p>
  
  <pre><code>ind &lt;- sample(2,nrow(mtcars), replace= T, prob = c(0.8,0.2))
  ind
  tdata &lt;- mtcars[ind==1,]  # select rows where ind = 1 ??!! but we don't have ind column in mtcars???
  vdata &lt;- mtcars[ind==2,]
  </code></pre>
  
  <p>Updated with my interpretation after help from Adam.</p>
  
  <ol>
  <li><code>ind</code>  -- independent stand alone ds with single column int. No any logical relationship to <code>mtcars</code>. I tested this creating it manually and it works OK.</li>
  <li>then it works with logical vector, matching rownum from mtcars to ind. Something like: let check row #1 from mtcars matching (by rownum)  row #1 from ind has value 1 so ind==1 translated to True and raw selected.</li>
  </ol>
  
  <p>Please correct me if I'm wrong. </p>