You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several permutations of calling binary operators on xts and matrix arguments results in a malformed xts object. If the xts object does not have a dim attribute, the result has a c("xts", "zoo") class, but no index attribute. The xts result will also have rownames if the matrix does.
data(sample_matrix)
x<- as.xts(sample_matrix[1:5, c(1,4)])
d<- coredata(x)
m<- as.matrix(x)
xv<- drop(x[,1])
# all these are okay: index, class, dim, dimnames (no rownames)
attributes(x-d)
attributes(x-m)
attributes(x-d[,1])
attributes(x-m[,1])
# these are various degrees of wrong
attributes(xv-d) # no index
attributes(xv-m) # no index, has rownames
attributes(xv-d[,1]) # okay
attributes(xv-m[,1]) # has names# not clear what is the correct behavior here# these pick up the dim attribute from the 1-column matrix
attributes(xv-d[, 1, drop=FALSE])
attributes(xv-m[, 1, drop=FALSE]) # has rownames
The result of Ops.xts() on an xts and a matrix will have rownames if
the matrix has rownames (e.g. if the matrix was created via as.xts()).
Always remove rownames from the Ops.xts() result, and remove dimnames
entirely if the result does not have colnames.
Add tests that exercise subtraction. Need to add tests that exercise
the relational operators.
See #295.
Calling Ops.xts() on a matrix and a xts object without a dim attribute
can result in an xts object without an index, and/or with a names
attribute.
Ensure there is never a names attribute, and that we always check if
the index exists.
Tests only exercise the subtraction operator. There should be tests
that use relational operators.
See #295.
These tests check all mathematic operations on all double, integer,
and logical types of xts objects. Still need to check relational
operators.
See #295.
Maintain the index type even though it is zero-length.
Previous behavior always returned a numeric index when Ops.xts() was
called on two xts objects that do not share any common index elements.
See #295.
The Ops unit tests only covered arithmetic operations. Add tests for
relational operations. We have to explicitly convert `E` to logical
because the `E[] <-` calls do not change the storage type.
Also rename the tests to use a more general 'ops' prefix.
test.ops_xts_no_dim_vector() failed for `&` on numeric types because
Ops.xts() would add dims. Update Ops.xts() to remove dims if neither
argument has a dim attribute.
See #295.
Several permutations of calling binary operators on xts and matrix arguments results in a malformed xts object. If the xts object does not have a dim attribute, the result has a
c("xts", "zoo")
class, but noindex
attribute. The xts result will also have rownames if the matrix does.Session Info
These were found as part of testing #245.
For reference, the behavior of the last 2 results is consistent with the current version (0.11-2):
The text was updated successfully, but these errors were encountered: