business-science / sweep

Extending broom for time series forecasting
https://business-science.github.io/sweep/
155 stars 31 forks source link

Vectorizing 'yearmon' elements may not preserve their attributes #5

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello,

I have been reproducing the examples that you have in Business Science and this warning is shown and therefore the dates doesn't appear like those you have in the blog post. I have seen that it's something related with dplyr...

This problem appears with the function sw_sweep

Warning messages:
1: In bind_rows_(x, .id) :
  Vectorizing 'yearmon' elements may not preserve their attributes
2: In bind_rows_(x, .id) :
  Vectorizing 'yearmon' elements may not preserve their attributes 

A reproducible example exist in this vignette

Cheers

mdancho84 commented 7 years ago

Yes, we are aware of this issue, and we've requested changes to retain yearmon and yearqtr classes when binding rows. The dplyr issue is: https://github.com/tidyverse/dplyr/issues/2457

sco-lo-digital commented 7 years ago

A way to get around it is to use zoo::as.Date(., frac=1) to coerce the yearmon or yearqtr object to a date. Then unnest has no problem with it.

mdancho84 commented 7 years ago

Nice hack!

ghost commented 7 years ago

The solution that I took it was convert to dates using zoo::as.Date.yearmon

SuperJohn commented 6 years ago

In reference to the example in the vignette, Forecasting Multiple Models, how do apply these hacks to resolve this issue? I can't figure out how or where to apply "zoo::as.Date(., frac=1)" to reconcile my dates. Thanks!

models_tbl_fcast_tidy %>%
  unnest(sweep) 

# Warning....1: In bind_rows_(x, .id)....Vectorizing 'yearmon' elements may not preserve their attributes