title: Data manipulation and pivoting
body: <p>I have a transactional data set where each transaction related to a customer appears in individual rows as shown below:</p>
  <pre><code>Customer_ID     Transaction_Date    Amount
  Cust_1           20-Dec-2020          100
  Cust_1           28-Dec-2020          800
  Cust_1           05-Jan-2021          300
  Cust_2           10-Jan-2021          200
  Cust_2           08-Feb-2021          300
  Cust_3           15-Feb-2021          500
  </code></pre>
  <p>I tried to transpose the dates into different columns with names &quot;1st_Trans_Date&quot;, &quot;2nd_Trans_Date&quot; etc, R gave me a sparse matrix with each unique date assigned to a column thereby generating 1000+ columns.</p>
  <p>I would like to have this data re-structured like below in different columns with some computations:</p>
  <pre><code>Customer_ID    1st_Trans_Date    2nd_Trans_Date    3rd_Trans_Date    Total_Trans    Total_Amt    Avg_Amt
  Cust_1         20-Dec-2020       28-Dec-2020       05-Jan-2021         3             1200         400
  Cust_2         10-Jan-2021       08-Feb-2021                           2              500         250
  Cust_3         15-Feb-2021                                             1              500         500 
   
  
  </code></pre>