title: R: using gsub in a for loop
body: <p>Low level R user here. </p>
  
  <p>I have 3 population data frames (low.proj, med.proj, high.proj) with the exact same number of rows and columns I'm trying to clean and reshape.</p>
  
  <p>I want to eliminate some extra commas in the country column all three of the frames so I'm trying this loop with gsub:</p>
  
  <pre><code>for(i in c("low.proj", "med.proj", "high.proj")){
      i$Country &lt;- gsub(",","",i[,"Country"])
      }
  </code></pre>
  
  <p>When I run this I get the error "Error in i[, "Country"] : incorrect number of dimensions"</p>
  
  <p>When I run the code without the loop:</p>
  
  <pre><code>low.proj$Country &lt;- gsub(",","",low.proj[,"Country"])
  </code></pre>
  
  <p>It works. What causes this error and how do I fix it?</p>