joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
220 stars 71 forks source link

period.apply will change the index from "Date" to "POSIXct" type in xts 0.12.0 #341

Closed testagaintestagain closed 3 years ago

testagaintestagain commented 3 years ago

Description

I caught this issue after upgrading from xts 0.11.2 to 0.12.0, The period.apply will change the index from "Date" to "POSIXct" type (along with a timezone inconsistency warning). This behavior will cause problems as commented in the reproducible example below.

As I checked, the changes were triggered by changes in .xts (called in reclass, which is used in period.apply)

Minimal, reproducible example

x <- xts(1:10, Sys.Date()+1:10)
xW <- apply.weekly(x, sum)
cat(class(index(x)), class(index(xW)))

# newIndex <- seq(index(xW[1]), index(xW[10]), by = 1) --> this dominates how this would cause problem

Session Info

R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    
joshuaulrich commented 3 years ago

I believe this is a duplicate of #322. Please use the latest GitHub version to confirm.

testagaintestagain commented 3 years ago

Thanks for the quick response. You are right.

joshuaulrich commented 3 years ago

Great, thanks! Also, you can expect a new xts release over the weekend. It needs to be on CRAN by 9/9. Make sure you re-install then to get the latest production release.

testagaintestagain commented 3 years ago

Great! Looking forward to it. And thanks for your amazing work. I have been using xts and TTR for more than 10 years.