Skip to content

Instantly share code, notes, and snippets.

@baditaflorin
Last active October 11, 2016 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baditaflorin/46b35b3044f69ed329e4c44067b7b246 to your computer and use it in GitHub Desktop.
Save baditaflorin/46b35b3044f69ed329e4c44067b7b246 to your computer and use it in GitHub Desktop.
x <- structure(c("2012-09-27 09:08:37", "2012-09-29 10:06:33", "2012-10-01 09:44:36","2012-10-04 14:37:05", "2012-10-15 13:18:21", "2012-10-17 17:33:46","2012-10-18 11:52:13", "2016-10-06 15:11:01", "2016-10-07 13:00:09","2016-10-07 12:20:57"), class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", format = "%Y-%m-%d %H:%M:%S", index = structure(c(1348704000,1348876800, 1349049600, 1349308800, 1350259200, 1350432000, 1350518400,1475712000, 1475798400, 1475798400), tzone = "UTC", tclass = "Date"), .Dim = c(10L,1L))
y <- structure(c("1961-08-04 10:00:00", "1971-01-01 11:00:00", "1978-01-01 11:00:00","1979-01-01 11:00:00", "1983-01-01 11:00:00", "1984-01-01 11:00:00","1985-01-01 11:00:00", "2016-10-07 20:28:24", "2016-10-07 18:27:54","2016-10-08 00:38:40"), class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", format = "%Y-%m-%d %H:%M:%S", index = structure(c(-265420800,31536000, 252460800, 283996800, 410227200, 441763200, 473385600,1475798400, 1475798400, 1475884800), tzone = "UTC", tclass = "Date"), .Dim = c(10L,1L))
x+y
#expected result
# get results
#what happens
#Error in `+.default`(x, y) : non-numeric argument to binary operator
#Working Example
a <- structure(c(1, 1, 1), .Dim = c(3L, 1L), index = structure(c(1422057600, 1422144000, 1422230400), tzone = "", tclass = c("POSIXt", "POSIXct")), .indexCLASS = c("POSIXt", "POSIXct"), .indexTZ = "", tclass = c("POSIXt", "POSIXct"), tzone = "", .Dimnames = list(NULL, "a"), class = c("xts","zoo"))
b <- structure(2, .Dim = c(1L, 1L), index = structure(1422057600, tzone = "", tclass = c("POSIXt", "POSIXct")), .indexCLASS = c("POSIXt", "POSIXct"), .indexTZ = "", tclass = c("POSIXt", "POSIXct"), tzone = "", .Dimnames = list(NULL, "b"), class = c("xts",
"POSIXct"), tzone = "", .Dimnames = list(NULL, "b"), class = c("xts",
a+b
#expected result
# a
# 2015-01-23 16:00:00 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment