-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected error extracting intervals from dates given as POSIXct or datetime format #286
Comments
From the FAQ (https://tsibble.tidyverts.org/articles/faq.html)
When you convert dates into datetimes you introduce time variations between some observations. While most observations will be 24 hours apart, some could be 23 hours or 25 hours apart due to daylight savings. So the common interval could be 1 hour, 30 minutes, 24 hours, or something else depending on the timezone of the datetime. For your particular example, there are no timezone shifts so I agree that the correct interval here should be 24 hours (note not 1 day as days may not have the same duration). It's a bit pedantic, but if you have daily data you should use a daily precision to avoid these complications. |
Thanks @mitchelloharawild , I thought it might be something like that. Really appreciate the excellent details here. Datetime math is always confusing. I may not be following properly though, here -- wouldn't this require a conversion to be ambiguous about timezone in order for my coercion to be ambiguous? My reprex coerces dates to datetimes just to create the reprex -- in my actual use case I just have datetime data (with timezone) but hit the same error. The lubridate coercion above attaches an explicit timezone as well doesn't it? Shouldn't the interval be unambiguous with datetime data that includes timezone information? Even if the interval is ambiguous here, I guess I don't really understand what I definitely appreciate that |
The
What happens when you explicitly define the timezone as UTC or whichever is most appropriate? |
Thanks @mitchelloharawild . The above example is already explicitly setting the timezone as UTC, but we still get the error as shown in the reprex. ( Thanks for the note about |
Turning dates to datetimes results in an undefined interval, causing tsibble to fail to parse the index correctly.
I would expect that if
index_valid(datetime)
is true, I could usedatetime
as a valid index inas_tsibble()
.Consider the following minimal reprex:
We define a sequence of dates as datetime data:
Above, {tsibble} tells us YES this is still a valid index! But it cannot calculate the interval:
and so we cannot actually use this index as a tsibble index:
Created on 2022-08-22 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: