title: Exporting Excel files in R based on Categories in a Column
body: <p>I want to export multiple excel data files for a single data frame for each category in a specific column. For example, I've 50 student scores from five states. How can I export each state student scores in separate excel file. Furthermore, when I export KS student scores in a separate excel file, I want R to save the name of the file with the state name (i.e. KS.xlsx). (I'd like to use 'excel_xlsx' from 'openxlsx' library if possible.</p>
  <p>Here is simulated data for explanation:</p>
  <pre><code>states = rep(c(&quot;AR&quot;, &quot;KS&quot;, &quot;CA&quot;, &quot;MO&quot;, &quot;NE&quot;),times = c(10, 5, 15, 8, 12))
  scores = rnorm(50, mean=30, sd=5)
  dat = data.frame(states, scores)
  </code></pre>
  <p>Thanks in advance.</p>