I've got a horrendously large dataframe (covering hundreds of days worth of data) that contains data of the following pattern:
df = data.frame(date = c('2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09', '2021-01-09'),
category = c(UKS, USD, UKS, UKS, USD, USD, UKS, USD, UKZ, UKY),
time = c(07:59:53, 08:00:03, 08:00:03, 08:00:03, 08:00:03, 08:00:04, 08:00:08, 08:00:11, 08:00:14, 08:00:15)
quantity = c(0.001, 0.003, 0.018, 0.010, 0.043, 0.005, 0.023, 0.005, 0.001, 0.008)
cumvol = c(0.001, 0.004, 0.022, 0.032, 0.075, 0.080, 0.103, 0.108, 0.109, 0.117)
type = c(TSV, OSN, TSS, TSV, TSS, TSS, OSN, TSV, OSN, TSS)
This dataframe cannot be changed, however what I would like to do is create a 'summary' dataframe from this one that sums together the total quantity for each category and type per day, as well as providing a total quantity on that day.
So using the above example:
For 2021-01-09
Total Quantity = 0.117
Total UKS = 0.052
Total USD = 0.056
Total UKZ = 0.001
Total UKY = 0.008
Does anyone have any advice on how to achieve this for all the days I have data for?