title: Aggregate data by two variables and count the number of times the value of a third variable appears
body: <p>I have this type of database in an Excel file</p>
  <pre><code>UGA     Date     Product
  A      05/2018   AM
  Z.     06/2019   BX
  X.     01/2020   AM
  M.     02/2017   AM
  B.     03/2019   AM/BX
  M.     04/2018   BX
  </code></pre>
  <p>The variable Product can take three types of value: AM, BX or AM/BX</p>
  <p>And I would like to get this type of table by using R code</p>
  <pre><code>UGA   Date      Nb_AM   Nb_BX
  A     01/2017   4       14
  A     02/2017   5       17
  A     03/2017   2       24
  B     01/2017   3       35
  B     02/2017   10      42
  B     03/2017   24      2
  </code></pre>
  <p>I want to aggregate the data by UGA and by date and create two new columns Nb_AM and Nb_BX and I don't want to display the column &quot;product&quot; anymore</p>
  <p>With Nb_AM corresponding to the number of apparition of &quot;AM&quot; and &quot;AM/BX&quot; for a date and an UGA</p>
  <p>And Nb_BX corresponding to the number of &quot;BX&quot; and &quot;AM/BX&quot; for a date and an UGA</p>
  <p>I think I should use the aggregate command but I have no idea how to use it Could you please help me?</p>
  <p>For the moment I just have this code :</p>
  <pre><code> am &lt;- read_excel(&quot;C:/Users/david/OneDrive/Bureau/Master data/Mémoire data analyst/Bases de 
   données/Ventes/AM_per_UGA.xlsx&quot;)
  </code></pre>
  <p>Thank you very much!</p>