Skip to content

Commit

Permalink
Add check.names = FALSE to merge() in Ops.xts()
Browse files Browse the repository at this point in the history
The check.names functionality was added to merge.xts() in commit
81df3f0. Setting it to FALSE in
Ops.xts() makes it consistent with Ops.zoo.

Fixes #114.
  • Loading branch information
joshuaulrich committed Oct 11, 2022
1 parent e8497a6 commit 4b93da7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/Ops.xts.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function(e1, e2)
.Class <- "matrix"
NextMethod(.Generic)
} else {
tmp.e1 <- merge.xts(e1, e2, all=FALSE, retclass=FALSE, retside=c(TRUE,FALSE))
e2 <- merge.xts(e2, e1, all=FALSE, retclass=FALSE, retside=c(TRUE,FALSE))
tmp.e1 <- merge.xts(e1, e2, all=FALSE, retclass=FALSE, retside=c(TRUE,FALSE), check.names=FALSE)
e2 <- merge.xts(e2, e1, all=FALSE, retclass=FALSE, retside=c(TRUE,FALSE), check.names=FALSE)
e1 <- tmp.e1
.Class <- "matrix"
NextMethod(.Generic)
Expand Down
9 changes: 9 additions & 0 deletions inst/unitTests/runit.Ops.R
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,12 @@ test.tzone_after_rel_op <- function() {
checkIdentical(tzone(ts2 == 0), tstz)
checkIdentical(tzone(ts2 != 0), tstz)
}

test.Ops.xts_does_not_change_column_names <- function() {
x <- .xts(1:3, 1:3, dimnames = list(NULL, c("-1")))
z <- as.zoo(x)
checkEquals(names(x + x[-1,]), names(z + z[-1,]),
"Ops.xts() doesn't change column names when merge() is called")
checkEquals(names(x + x), names(z + z),
"Ops.xts() doesn't change column names when indexes are equal")
}

0 comments on commit 4b93da7

Please sign in to comment.