Error: object not found - I don't understand why I'm getting this error

So, I'm trying to replicate the process found here: Forecasting for prophet in R

I'm running into this: Error in .(as.factor(lubridate::wday(ds))) : could not find function "."

After running the following line of code

uwdays <- traindf[,.(.N, w=min(ds)),.(as.factor(lubridate::wday(ds)))]$w

When I remove the "." before (as.factor(...w I get Error in lubridate::wday(ds) : object 'ds' not found. Yet, I know ds exists in traindf!

Any ideas?

The line of code above is for use in the following plot

#Day of Week
uwdays <- traindf[,.(.N, w=min(ds)),.(as.factor(lubridate::wday(ds)))]$w
days <- lubridate::wday(uwdays,label = TRUE)

ggplot(aes(y=pred2,x=lubridate::wday(ds)),
       data = traindf[ds %in% uwdays]) +
  scale_x_continuous(breaks=1:length(days),labels=days) +
  labs(title="Day of Week",x="Day",y="Daily Census") +
  ylim(0,1.25*max(traindf$pred2)) +
  geom_point() +
  geom_line()

#Monthly
umonths <- traindf[,.(.N, w=min(ds)),.(as.factor(lubridate::month(ds)))]$w
months <- lubridate::month(umonths,label=TRUE)

ggplot(aes(y=pred3,x=lubridate::month(ds)),
       data = traindf[ds %in% umonths]) +
  scale_x_continuous(breaks=1:length(months),labels=months) +
  labs(title="Month",x="Month",y="Daily Census") +
  ylim(0,1.25*max(traindf$pred3)) +
  geom_point() +
  geom_line()

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.