title: Add the years to the column and summarize the value in R
body: <p>I have a data frame as below</p>
  
  <pre><code>cust start-dt    end-dt      item item_type sales cost trans-dat
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx 1500  1400 08-01-2019
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx 2000  1600 09-01-2019
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx 2500  1000 07-12-2019
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx 1600  1300 05-01-2020
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx 2400  1700 02-01-2020
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx 2200  1300 04-01-2020
  </code></pre>
  
  <p>I need to convert to year wise data as below. 
  based on the customer and the item they bought across every year </p>
  
  <pre><code>cust start-dt    end-dt      item item_type  year sales cost
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx  2019 6000  4000
  A    07-01-2019  07-01-2020  AA   xxxxxxxxx  2020 6200  4300
  
  </code></pre>
  
  <p>i tried melt and cast but melt doesnt create new columns/rows.</p>
  
  <p>this data is only an example. I have multiple customers and multiple items for every customer and the start and end also differs for every cust. </p>
  
  <p>Please guide me on how to approach the issue. </p>