title: How to use string value as a column selector in a for loop
body: <p>I have a for loop that looks like this</p>
  <pre><code>for (j in c(&quot;Month_1&quot;, &quot;Month_2&quot;, &quot;Month_3&quot;, &quot;Month_4&quot;)) {
    r &lt;- ggplot(df_tableAcc[df_tableAcc$j &gt; 100,]) + 
      aes_string(x = &quot;ShipSog&quot;) + 
      geom_bar()
    
    print(r)
  }
  
  </code></pre>
  <p>Where the column names in df_tableAcc is &quot;Month_1&quot;, &quot;Month_2&quot;, &quot;Month_3&quot;, &quot;Month_4&quot;.</p>
  <p>How can I use the &quot;[df_tableAcc$<strong>j</strong> &gt; 100,&quot; ?</p>
  <p>I keep getting this error:</p>
  <blockquote>
  <p>Warning: Unknown or uninitialised column: <code>j</code>.
  Error: Must subset rows with a valid subscript vector. i Logical subscripts must match the
  size of the indexed input. x Input has size 1852 but subscript
  <code>df_tableAcc$j &gt; 100</code> has size 0.</p>
  </blockquote>