title: Apply dplyr function to many files
body: <p>I'd like to loop a dplyr function through a directory of csv files. I know how to implement the command for a single file, but it would be helpful to do it for the whole directory to speed up the process, as well as create an output file that contains the summarized data for each file the function was applied to. </p>
  
  <p>Essentially, each csv file contains information on species sampled in a community, across multiple host plants and years. I'd like to summarize the number of unique taxa sampled by host plant and year. I can do that using:</p>
  
  <pre><code>taxa &lt;- file %&gt;% group_by(crop, year) %&gt;% summarise(num_taxa=n_distinct(taxon))
  </code></pre>
  
  <p>In looking at some examples on here, I know how to read in a list of files and setup the function application using lapply. However, I'm having difficulty actually embedding a working function and creation of an output file with summary data for all files. Any tips would be greatly appreciated. </p>