I have a table in Rstudio and my table had 4 attributes and I want to know how to calculate the forecast for example the sum of the sales in the previous 5 days
Something tells me that this is from a school-assignement, so I won't give you the entire answer.
Say your table looks somewhat like this
id | date | sales |
---|---|---|
1 | 2021-12-30 | 100 |
2 | 2021-12-31 | 110 |
3 | 2022-01-01 | 120 |
4 | 2022-02-01 | 130 |
5 | 2022-03-01 | 140 |
6 | 2022-04-01 | 150 |
7 | 2022-05-01 | 160 |
The algorithm for computing the sum of the last five days, say between 2021-12-31 and 2022-01-04, would be something a long the lines of
If you can use dplyr , you could probably do everything in two lines of code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.