So I used this post to sum up my data by month in R, but the problem is, my data goes over multiple years. The current solution will treat, say, Jan 2018 and Jan 2019 as the same month. Is there a way to have them separated by month using the aggregate() and month() functions? Or will I have to change my approach?
My data frame looks like this:
Day Sales
1 2019-02-04 219.12
2 2019-02-04 60.84
3 2019-02-05 200.27
4 2020-02-11 157.17
5 2020-02-12 12.14
And my function looks like this:
bymonth<-aggregate(sales~month(day,label=TRUE),data=total.orders.by.date,FUN=sum)
Thanks