title: Aggregate Column from Data Frame 1 and Insert to Data Frame 2
body: <p>I am using R 3.5.1. </p>
  
  <p>I have the following data frames:  <strong>Sales</strong> and <strong>Freight</strong>.</p>
  
  <pre><code>&gt; Freight = data.frame(CustomerId = c("A","A","B","B","C","C"), Product = c("1","2","1","2","1","2"), Cost=c(207,409,116,335,42,222))
  &gt; 
  &gt; Freight
    CustomerId Product Cost
  1          A       1  207
  2          A       2  409
  3          B       1  116
  4          B       2  335
  5          C       1   42
  6          C       2  222
  
  
  &gt; Sales_DF &lt;- data.frame(CustomerID = c("A" ,"A","A","A","B","B","B","B","C","C","C","C"), TransactionDate = c("2/14/2018","1/7/2018","2/22/2018","1/14/2018","2/10/2018","1/13/2018","2/3/2018","1/14/2018", "2/19/2018","1/9/2018","2/20/2018","1/23/2018"),Shipment=c(176,54,175,60,118,262,257,470,474,438,82,305))
  &gt; Sales_DF
     CustomerID TransactionDate
  1           A       2/14/2018
  2           A        1/7/2018
  3           A       2/22/2018
  4           A       1/14/2018
  5           B       2/10/2018
  6           B       1/13/2018
  7           B        2/3/2018
  8           B       1/14/2018
  9           C       2/19/2018
  10          C        1/9/2018
  11          C       2/20/2018
  12          C       1/23/2018
     Shipment
  1       176
  2        54
  3       175
  4        60
  5       118
  6       262
  7       257
  8       470
  9       474
  10      438
  11       82
  12      305
  </code></pre>
  
  <p>How can I aggregate the shipments in <strong>Sales</strong> for each customer and for each month and insert it as a column to <strong>Freight</strong>? </p>
  
  <p>Output wanted.</p>
  
  <pre><code>Customer    Month   Cost    Shipment
  A             1      207    114
  A             2      409    351
  B             1      116    732
  B             2      335    375
  C             1       42    743
  C             2      222    556
  </code></pre>