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

last.default on Dates - incorrect number of dimensions #303

Closed gsee closed 5 years ago

gsee commented 5 years ago

Description

Calling last on Date vectors when n is character results in an error.

Expected behavior

This worked in older versions of xts:

> last(as.Date(0)+1:5, "2 days")
[1] "1970-01-05" "1970-01-06"

Minimal, reproducible example

> last(as.Date(0)+1:5, "2 days")
Error in `[.default`(x, (NROW(x) - n + 1):NROW(x), , drop = FALSE) : 
  incorrect number of dimensions

Session Info

R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] xts_0.12-1 zoo_1.8-6 

loaded via a namespace (and not attached):
[1] compiler_3.6.0  grid_3.6.0      lattice_0.20-38
joshuaulrich commented 5 years ago

Thanks for testing the development version of xts, and for this bug report! This should be fixed now. Please continue testing and let me know if you find any other issues.