[R] Problems merging with POSIXct objects and all = TRUE

Martin Maechler maechler at stat.math.ethz.ch
Mon Oct 15 11:39:24 CEST 2001


>>>>> "David" == "David Kane <David Kane" <a296180 at mica.fmr.com> writes:

    David> I am having problems using merge with all = TRUE when one of the
    David> dataframes has objects of class POSIXct. If this is a bug, let
    David> me know and I will report it to r-bugs. Here is an example:

    ... (R version 1.3.0)

 > x <- data.frame(a = as.POSIXct(Sys.time() + (1:3)*10000), b = LETTERS[1:3])
 > x
		     a b
 1 2001-10-04 17:37:46 A
 2 2001-10-04 20:24:26 B
 3 2001-10-04 23:11:06 C

 > y <- data.frame(b = LETTERS[3:4], c = 1:2)
 > y
   b c
 1 C 1
 2 D 2

 > merge(x, y)
   b                   a c
 1 C 2001-10-04 23:11:06 1		# This answer is correct

 > merge(x, y, all = TRUE)
 Error in as.POSIXct.default(value) : Don't know how to convert `value' to class "POSIXct"

-------------

The reason is that merge(x,y, all = TRUE) fills in NAs at "appropriate"
places, and currently, it seems we have no (automatic) NA concept for
POSIX[cl]t objects:

 > as.POSIXlt(NA)
 Error in as.POSIXlt(NA) : Don't know how to convert `NA' to class "POSIXlt"
 > as.POSIXct(NA)
 Error in as.POSIXct.default(NA) : Don't know how to convert `NA' to class "POSIXct"
 > as.POSIXct("NA")
 Error in fromchar(x) : character string is not in a standard unambiguous format

This might be considered a bug although only in a loose sense of the word.

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list