I have a matrix that looks like this:
date 1 2 3 4
201601 2 4 6 1
201602 3 7 7 4
201603 4 8 9 6
201604 6 4 5 7
Rows indicates prod_Date and column header (1 to 4) the age. The numbers indicates the sales of the product.
I need to generate a dataframe that has PER YEAR, the comulative sum of sales, and also, I want to multiply this by a "maturity" factor which is given by Age/max(Age) - in this case for example 1/4 or 2/4. please note age could vary. The final output should look like this:
age cum.sales sales*maturity
1 15 3.75
2 38 19.00
3 65 48.75
4 83 83.00
Any reccomandation on how to do it fast? Thanks in advance