Open fcasarramona opened 9 years ago
To clarify, this works with matrix and zoo objects because [[
with character i
matches on rownames (technically, dimnames(x)[[1]]
), but xts objects do not have rownames.
> sample_matrix[["2007-06-28",1]]
[1] 47.67604
> as.zoo(sample_matrix)[["2007-06-28",1]]
[1] 47.67604
> as.xts(sample_matrix)[["2007-06-28",1]]
Error in as.xts(sample_matrix)[["2007-06-28", 1]] :
subscript out of bounds
I think the solution would be to create a [[.xts
method.
While is posible to select one single element of a
xts
object with single square brakets:returning a
xts
object, selecting with double square brackets returns an error:but I expect returning a numeric.
Workarrounds are:
or, type independent: