title: How to loop through columns in R to create plots?
body: <p>I have three columns in a dataframe: age, gender and income.</p>
  <p>I want to loop through these columns and create plots based on the data in them.</p>
  <p>I know in stata you can loop through variables and then run commands with those variables. However the code below does not seem to work, is there an equivalent way to do what I want to do in R?</p>
  <pre><code>groups &lt;- c(df$age, df$gender, df$income) 
  for (i in groups){   
  df %&gt;% group_by(i) %&gt;%
      summarise(n = n()) %&gt;%
      mutate(prop = n/sum(n)) %&gt;%
      ggplot(aes(y = prop, x = i)) +
      geom_col()  
  }
  </code></pre>