title: Why does R store the loop variable/index/dummy in memory?
body: <p>I've noticed that <code>R</code> keeps the index from <code>for</code> loops stored in the global environment, e.g.:</p>
  
  <pre><code>for (ii in 1:5){ }
  
  print(ii)
  # [1] 5
  </code></pre>
  
  <p>Is it common for people to have any need for this index after running the loop?</p>
  
  <p>I never use it, and am forced to remember to add <code>rm(ii)</code> after every loop I run (first, because I'm anal about keeping my namespace clean and second, for memory, because I sometimes loop over lists of <code>data.tables</code>--in my code right now, I have 357MB-worth of dummy variables wasting space).</p>
  
  <p>Is there an easy way to get around this annoyance?
  Perfect would be a global option to set (<em>a la</em> <code>options(keep_for_index = FALSE)</code>; something like <code>for(ii in 1:5, keep_index = FALSE)</code> could be acceptable as well. </p>