Skip to content
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

window function works in version 0.9-7 not working in version 0.11-2 #312

Closed
annaymj opened this issue Oct 30, 2019 · 5 comments
Closed
Labels
Milestone

Comments

@annaymj
Copy link

annaymj commented Oct 30, 2019

The window function works in an older version (0.9-7), but fails the new version.

out.early.xts.window <- window(out.early.xts,start=1995.00)
Error in .toPOSIXct(start, indexTZ(x)) : invalid time / time based class

Can you share an example of work around ?

Was trying to install the old version using the following command, but runs into compilation issue

require(devtools)
install_version("xts", "0.9-7","http://cran.us.r-project.org")
ERROR: compilation failed for package 'xts'
@ethanbsmith
Copy link
Contributor

what is 1995.00 is supposed to represent?
maybe you want out.early.xts.window <- window(out.early.xts, start=.POSIXct(1995.00))
or out.early.xts.window <- window(out.early.xts, start=as.POSIXct("1995-01-01"))

@annaymj
Copy link
Author

annaymj commented Oct 31, 2019

It's the year name. The workaround code seems working.

Thank you!

@annaymj
Copy link
Author

annaymj commented Nov 8, 2019

Update. 1995.00 means year 1995 quarter Q1. 1996.25 (1996 Q2). Those works in the old library version.

.POSIXct(1995.00) is returning very weird result.

.POSIXct(1995.00)
[1] "1970-01-01 00:33:15 UTC"

as.POSIXct("1995-01-01") is working

as.POSIXct("1995-01-01")
[1] "1995-01-01 UTC"
Do you have an easy method to convert 1995.00 to "1995-01-01"?

Also do you have plan to make 1995.00 format working for the updated version?

Thanks a lot!

@joshuaulrich
Copy link
Owner

Hi @annaymj. I'll investigate the prior behavior and make sure it is not broken in the new version.

@joshuaulrich
Copy link
Owner

joshuaulrich commented Nov 19, 2019

Hi @annaymj, can you please provide an example of the out.early.xts and out.early.xts.window objects, when run under 0.9-7? The window.xts() method was added in 0.11-0, so window.zoo() would have been dispatched in any prior version of xts.

I can get your example to work if the index is yearmon or yearqtr, but not if it's Date.

R> x <- xts(1:12, seq(as.yearqtr(2007), by=1/4, length.out=12))
R> window(x, start=2009)
        [,1]
2009 Q1    9
2009 Q2   10
2009 Q3   11
2009 Q4   12
R> ix <- seq(as.yearmon(2007), by=1/12, length.out=36)
R> head(window(xts(1:36, ix), start=2009))
         [,1]
Jan 2009   25
Feb 2009   26
Mar 2009   27
Apr 2009   28
May 2009   29
Jun 2009   30
R> ix <- as.Date(ix)
R> head(window(xts(1:36, ix), start=2009))  # starts in 2007, not 2009
           [,1]
2007-01-01    1
2007-02-01    2
2007-03-01    3
2007-04-01    4
2007-05-01    5
2007-06-01    6
R> packageVersion("xts")
[1] '0.9.7'

@joshuaulrich joshuaulrich added this to the 0.12.2 milestone Sep 15, 2020
joshuaulrich added a commit that referenced this issue Sep 15, 2020
joshuaulrich added a commit that referenced this issue Sep 16, 2020
This is getting out of hand.

See #312.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants