business-science/sweep

Vectorizing 'yearmon' elements may not preserve their attributes

Opened this issue · 5 comments

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

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: tidyverse/dplyr#2457

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.

Nice hack!

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

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