This is a continuation question from this answer: https://mcmap.net/q/899232/-using-prophet-package-to-predict-by-group-in-dataframe-in-r
I am using the do
function in dplyr
within the prophet
package. When attempting this I want to make a future dataframe with weekends excluded. Below is my current code:
Current dataframe:
dataset
ds group y
2021-12-15 A 5
2021-12-16 A 6
2021-12-15 B 10
2021-12-16 B 7
etc etc etc
Prediction
library(dplyr)
library(prophet)
data = dataset %>%
group_by(group) %>%
do(predict(prophet(., daily.seasonality = TRUE, yearly.seasonality = TRUE),
make_future_dataframe(prophet(.,daily.seasonality = TRUE, yearly.seasonality = TRUE), periods = 14))) %>%
select(ds, group, yhat)
How do I rewrite the above code to filter for the make_future_dataframe
dataset not have weekends?
I want it to looks something like this, however this is not working:
data = dataset %>%
group_by(group) %>%
do(predict(prophet(., daily.seasonality = TRUE, yearly.seasonality = TRUE),
make_future_dataframe(prophet(.[which(weekdays(.$ds) != 'Saturday' | weekdays(.$ds) != 'Sunday'),],daily.seasonality = TRUE, yearly.seasonality = TRUE), periods = 14))) %>%
select(ds, group, yhat)