title: Proper way to loop over the length of a dataframe in R
body: <p>After quite a bit of debugging today, to my dismay i found that:</p>
  
  <pre><code>for (i in 1:0) {
       print(i)
  }
  </code></pre>
  
  <p>Actually prints 1 and 0 respectively in R. The problem came up when writing  </p>
  
  <pre><code>for (i in 1:nrow(myframe) {
       fn(i)
  }
  </code></pre>
  
  <p>Which i had intended to not execute at all if nrow(myframe)==0. Is the proper correction just:</p>
  
  <pre><code>if (nrow(myvect) != 0) {
      for (i in 1:nrow(myframe) {
          fn(i)
      }
  }
  </code></pre>
  
  <p>Or is there a more proper way to do what I wanted in R?</p>