Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-Forge #4904] reclass() doesn't copy tzone attributes from match.to object #43

Closed
joshuaulrich opened this issue Feb 26, 2015 · 1 comment
Labels
Milestone

Comments

@joshuaulrich
Copy link
Owner

Submitted by: Joshua Ulrich
Assigned to: Joshua Ulrich
R-Forge link

The problem manifests in this SO question because the user doesn't have the #10 [R-Forge #2750] bug fix, but the code below reproduces the issue even with the bug fix.

x <- structure(c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE),
  .indexCLASS = 'Date', .indexTZ = 'UTC', tclass = 'Date', tzone = '',
  class = c('xts', 'zoo'), index = structure(c(1357084800, 1357171200,
  1357257600, 1357516800, 1357603200, 1357689600), tzone = '',
  tclass = 'Date'), .Dim = c(6L, 1L), .Dimnames = list(NULL, 'YHOO.Close'))

y <- structure(c(20.08, 19.78, 19.86, 19.4, 19.66, 19.33),
  .indexCLASS = 'Date', tclass = 'Date', .indexTZ = 'UTC', tzone = 'UTC',
  src = 'google', updated = structure(1379249836.73162,
  class = c('POSIXct', 'POSIXt')), class = c('xts', 'zoo'),
  index = structure(c(1357084800, 1357171200, 1357257600, 1357516800,
  1357603200, 1357689600), tzone = 'UTC', tclass = 'Date'), .Dim = c(6L, 1L),
  .Dimnames = list(NULL, 'YHOO.Close'))

# missing tzone attributes
z <- reclass(x, y)
@joshuaulrich
Copy link
Owner Author

joshuaulrich commented Oct 12, 2022

A simplified example:

x <- xts(1:5, .Date(1:5))
tzone(x) <- ""
tclass(x) <- c("POSIXct", "POSIXt")

y <- xts(1:5, .Date(1:5))
xtsAttributes(y) <- list("hello" = "world")

z <- reclass(x, y)

tzone(z) == tzone(y)    # FALSE (should be TRUE)
tclass(z) == tclass(y)  # FALSE (should be TRUE)
all.equal(xtsAttributes(z), xtsAttributes(y))  # TRUE

@joshuaulrich joshuaulrich added this to the 0.12.3 milestone Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant