xts icon indicating copy to clipboard operation
xts copied to clipboard

subset inconsistent with zoo when 'i' contains NA

Open joshuaulrich opened this issue 2 years ago • 0 comments

xts subset does not allow NA in 'i' like zoo does.

require(xts)
x <- .xts(matrix(1:20, 10, 2), 1:10)
z <- as.zoo(x)
i <- c(1, NA, 5)

z[i,]
##                          
## 1969-12-31 18:00:01  1 11
## 1969-12-31 18:00:05  5 15
## <NA>                NA NA

x[i,]
## Error in `[.xts`(x, i, ) : 
##   only zeros may be mixed with negative subscripts

Making this consistent will not be a breaking change since it is currently an error in xts.

joshuaulrich avatar Feb 06 '24 21:02 joshuaulrich