I want to add another column to my dataframe in R, containing the sum of the amount of orders, when the other columns are the same.
For example if this is my data frame:
orderdate / orderhour / deliverydate / deliveryhour / orders / New column: sum
wednesday / 12:00 / Friday / 17:00 / 5 / 0
wednesday / 12:00 / Friday / 17:00 / 2 / 7
thursday / 13:00 / Friday / 17:00 / 3 / 3
thursday/ 13:00 / Friday / 19:00 / 1 / 1
The last column is the one I want to add. In the end, the rows with zero can be removed, so I no longer have duplicate data. So only if all columns match (except orders) the sum of the orders should be taken. In the other cases the same value can be kept.
Can someone please help me?
Thanks in advance!