Convert to POSIXct:
x$date <- as.POSIXct(x$date, tz = "GMT")
y$date <- as.POSIXct(y$date, tz = "GMT")
merge(x, y, all = TRUE)
On Mon, Dec 27, 2010 at 2:14 PM, Dimitri Shvorob
<dimitri.shvorob@gmail.com>wrote:
>
> x = structure(list(date = structure(list(sec = c(0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(0L, 0L,
> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> 0L, 0L, 0L), hour = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mday = c(1L, 2L,
> 3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 22L,
> 23L, 24L, 25L, 26L, 29L), mon = c(10L, 10L, 10L, 10L, 10L, 10L,
> 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
> 10L, 10L), year = c(110L, 110L, 110L, 110L, 110L, 110L, 110L,
> 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L,
> 110L, 110L, 110L), wday = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
> 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L), yday = c(304L,
> 305L, 306L, 307L, 308L, 311L, 312L, 313L, 314L, 315L, 318L, 319L,
> 320L, 321L, 322L, 325L, 326L, 327L, 328L, 329L, 332L), isdst = c(0L,
> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> 0L, 0L, 0L, 0L)), .Names = c("sec", "min",
"hour", "mday", "mon",
> "year", "wday", "yday", "isdst"),
class = c("POSIXt", "POSIXlt"
> )), n = c(8, 0, 2, 6, 0, 7, 0, 1, 9, 8, 10, 9, 3, 0, 0, 0, 0,
> 0, 0, 0, 0)), .Names = c("date", "n"), row.names =
c(NA, -21L
> ), class = "data.frame")
>
> y = structure(list(date = structure(list(sec = c(0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(0L, 0L,
> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> 0L, 0L, 0L), hour = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mday = c(1L, 2L,
> 3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 22L,
> 23L, 24L, 25L, 26L, 29L), mon = c(10L, 10L, 10L, 10L, 10L, 10L,
> 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
> 10L, 10L), year = c(110L, 110L, 110L, 110L, 110L, 110L, 110L,
> 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L, 110L,
> 110L, 110L, 110L), wday = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
> 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L), yday = c(304L,
> 305L, 306L, 307L, 308L, 311L, 312L, 313L, 314L, 315L, 318L, 319L,
> 320L, 321L, 322L, 325L, 326L, 327L, 328L, 329L, 332L), isdst = c(0L,
> 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
> 0L, 0L, 0L, 0L)), .Names = c("sec", "min",
"hour", "mday", "mon",
> "year", "wday", "yday", "isdst"),
class = c("POSIXt", "POSIXlt"
> )), m = c(114, 107, 51, 108, 0, 121, 86, 64, 108, 89, 128, 79,
> 70, 97, 115, 126, 72, 107, 0, 98, 76)), .Names = c("date",
"m"
> ), row.names = c(NA, -21L), class = "data.frame")
>
> > w = merge(x, y, all.x = T, all.y = T)
> Error in sort.list(bx[m$xi]) : 'x' must be atomic for
'sort.list'
> Have you called 'sort' on a list?
>
> Converting "date" to Date with "as.Date" fixes the
problem, but what if I
> could not ignore the time part?
>
> --
> View this message in context:
>
http://r.789695.n4.nabble.com/Can-t-merge-on-datetime-tp3165187p3165187.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]