[Rd] all.equal doesn't work for POSIXlt objects

From: Joris Meys <jorismeys_at_gmail.com>
Date: Mon, 08 Aug 2011 00:26:03 +0200


Hi all,

following sample code illustrates the problem :

  Date1 <- Date2 <-
as.POSIXlt(seq.Date(as.Date("2010-04-01"),as.Date("2011-04-01"),by='day'))   identical(Date1,Date2)

  all.equal(Date1,Date2)

identical() gives the correct answer. As there is no all.equal method for POSIXlt objects, all.equal.list is used instead. Subsetting using [[]] doesn't work on POSIXlt objects. I solved the problem by adding a function all.equal.POSIXlt() :

all.equal.POSIXlt <- function(target, current, ..., scale=1) {   check_tzones(target, current)
  target <- unclass(target)
  current <- unclass(current)

  NextMethod("all.equal.list")
}

This seems to work bugfree, but I'm not sure about it. So am I doing it correct, and if so, can this be added to the next R release? I'm not sure where else I should drop this proposal...

Cheers
Joris

-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys_at_Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sun 07 Aug 2011 - 23:10:09 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 08 Aug 2011 - 08:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive