title: How to sum columns in R according to categories in 2 different groups
body: <p>I have the following dataset imported from excel via "readxl::read_excel" command:</p>
  
  <pre><code>Municipality    Production  Type
  Atima           690         Reverification
  Atima           120         Reverification
  Atima           220         Reverification
  Comayagua       153         Initial
  Comayagua       193         Initial
  Comayagua       138         Initial
  Comayagua       307         Reverification
  Copán           179         Initial
  Copán           100         Initial
  Copán           236         Reverification
  Copán           141         Reverification
  Danlí            56         Reverification
  ...
  </code></pre>
  
  <p>Subsequently used the code below as the data was tbl_df.</p>
  
  <pre><code>df &lt;- as.data.frame(df) 
  </code></pre>
  
  <p>I want to sort the data by Type and add up the Production to get the total Production for each Municipality:</p>
  
  <pre><code>Municipality    Production  Type
  Atima           1030        Reverification
  Comayagua       484         Initial
  Comayagua       307         Reverification
  Copán           279         Initial
  Copán           377         Reverification
  Danlí            56         Reverification
  </code></pre>
  
  <p>I looked up in other post, but I was only able to find how to sum it up for one categorical variable. How could I do this in R? Or should I first do it in excel and then import the table? </p>
  
  <p>I'm working in Rstudio Version 0.99.441, in Windows 7.</p>
  
  <p>Thanks in advance for your help.</p>