Open MortenGrum opened 3 years ago
Thanks for the report! It looks like there are multiple bugs here...
You should be able to subset xts objects by selecting none of the columns. That should return a zero-width xts object (an object with an index but no columns). That happens, but the resulting object doesn't have the correct tzone
or tclass
from the object that was subset.
Then, head()
returns an object that has a column of NA
, as you showed. That's a bug in head()
(and tail()
). Strangely, that doesn't happen with first()
and last()
.
...subset xts objects by selecting none of the columns. ...but the resulting object doesn't have the correct tzone or tclass from the object that was subset. A subset that selects none of the columns now returns an xts object with the same tclass and tzone (related to #255 and #359).
I'm not sure whether or not this is a bug in head()
and tail()
. There are no xts methods for those functions, so head.zoo()
and tail.zoo()
are dispatched. Those functions depend on how subsetting zero-width xts/zoo objects work.
Subsetting a zero-width xts object without providing j
returns an xts object with one column of NA
. This is consistent with zoo. But subsetting a zero-width xts object with a value for j
returns a zero-width xts object. This is not consistent with zoo, which again returns an object with one column of NA
. @ggrothendieck, @zeileis what are your thoughts on this?
Description
Excluding the last column of an xts correctly leads to ncol() returning zero but at the same time introduces a new unnamed column with value NA.
Is this a bug?
Expected behavior
I would have expected an xts with same index and no columns.
Minimal, reproducible example
Session Info
I am working with xts_0.12.1 in R 4.1.0:
Thanks.