title: How to apply a function of creating csv file on groups at same time?
body: <p>I have already written a function that helps create a csv.file for each state. </p>
  
  <pre><code>specify.state &lt;- function(type.state) {
    new.state &lt;- any.drinking %&gt;% 
      filter(state == type.state)
      write.csv(new.state,paste("any_drinking_", type.state, ".csv"), row.names = FALSE)
  }
  </code></pre>
  
  <p>Since there are 51 states in my data frame, I'm wondering how to run this function for each state at the same time by using dplyr. So I can get 51 different files at the same time. </p>
  
  <p>Thank you very much for helping! </p>