title: How to remove variables using loop
body: <p>I have defined multiple variables on the global environment following the rule :</p>
  
  <pre><code>for (i in 1:999){
      assign(sprintf('Model%03d', i), something_i)
  }
  </code></pre>
  
  <p>i.e., I generated variables <code>Model001</code>, <code>Model002</code>, ..., <code>Model999</code>.</p>
  
  <p>But now I should remove those variables from the global environment.</p>
  
  <hr>
  
  <h3>What I tried</h3>
  
  <p>I tried the following </p>
  
  <pre><code>for (i in 1:999){
    rm(get(sprintf("Model%03d", i)))
  }
  </code></pre>
  
  <p>But I got the following error</p>
  
  <pre><code>Error in rm(get(sprintf("Model%03d", i))) : 
    ... must contain names or character strings
  </code></pre>
  
  <p>Alternatively, I tried</p>
  
  <pre><code>for (i in 1:999){
    rm(sprintf("Model%03d", i))
  }
  </code></pre>
  
  <p>but I have the same error message.</p>
  
  <p>I would like to know a shortcut to do this task, even it is quite "dangerous" from the developer's point of view. </p>
  
  <p>Any help will be appreciated.</p>