I have a daily revenue dataset df
from 2016-01-01
to 2017-05-21
. The dataset contains Datum
, languages
and Opbrengst
variables.
Datum lanuage Opbrengst
596 20160101 bg 254
923 20160101 bg-bg 434
1044 20160101 ca 115
1544 20160101 ca-es 238
2008 20160101 cs 251
....
I want to group by Datum
for the Opbrengst
.
I've tried the method from How to sum a variable by group?
aggregate(Datum ~ Opbrengst, data=df, FUN="sum")
or
tapply(df$Datum, df$Opbrengst, FUN=sum)
The results become
Opbrengst Datum
1 10 786304986
2 100 1048457710
3 1000 221796843
4 1000,01 20160628
5 1000,78 20170104
This is not the result I want. I want to have the sum of the revenue of each date. I am wondering where is the problem?