-
Notifications
You must be signed in to change notification settings - Fork 48
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
Error in yearmonth #290
Comments
This behavior is also having an impact on other functions, as library(tidyverse)
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, union
library(reprex)
x <- rnorm(40)
x <- cumsum(x)
t <- make_yearmonth(2001, 1)
y<- tsibble(m = t+0:39, x=x, index = m)
filter_index(y, "2001 Jul" ~. )
#> # A tsibble: 35 x 2 [1M]
#> m x
#> <mth> <dbl>
#> 1 2001 Jun 1.23
#> 2 2001 Jul 0.0794
#> 3 2001 Aug 0.948
#> 4 2001 Sep 2.00
#> 5 2001 Oct 0.860
#> 6 2001 Nov 1.47
#> 7 2001 Dec -0.187
#> 8 2002 Jan -1.17
#> 9 2002 Feb -0.682
#> 10 2002 Mar -0.910
#> # … with 25 more rows
```
<sup>Created on 2022-11-15 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup>
```
|
The issue seems specifically related to Bandaid solution
Example for 1 format date_str <- "2018 Jan"
# Bad output
tsibble::yearmonth(date_str)
# <yearmonth[1]>
# [1] "2017 Dec"
# Manual conversion and expected output
date <- as.Date(paste(date_str, "01"), format="%Y %b %d")
tsibble::yearmonth(date)
# <yearmonth[1]>
# [1] "2018 Jan" Example of working around issue by remove timezone info from date before applying
|
I believe this issue is caused by an issue in the |
looks like it gets fixed in upstream packages vspinu/timechange#24 thanks for the help! |
Hi,
There seems to be a bug in date conversions using
tsibble::yearmonth()
. See the example below.The error happens even if I use the
format
option, e.g.yearmonth(d, format = "%YM%m")
. This was working in the past. This issue may be related to time zones, but I'm not sure why, since I'm focusing on monthly data.Created on 2022-11-11 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: