From jeff.horner at vanderbilt.edu  Wed Feb 21 23:45:25 2007
From: jeff.horner at vanderbilt.edu (Jeffrey Horner)
Date: Wed, 21 Feb 2007 16:45:25 -0600
Subject: [Rd] Adding difftime objects to POSIXt objects
In-Reply-To: <45DCC672.8070807@vanderbilt.edu>
References: <45DCC672.8070807@vanderbilt.edu>
Message-ID: <45DCCB85.50000@vanderbilt.edu>

Jeffrey Horner wrote:
> Hello,
> 
> ?DateTimeClasses states that "one can add or subtract a number of 
> seconds or a 'difftime' object from a date-time object, but not add two 
> date-time objects."
> 
> So, is the below expected behavior?
> 
>  > x <- Sys.time()
>  > x
> [1] "2007-02-21 16:19:56 CST"
>  > x + as.difftime("1","%H")
> [1] "2007-02-21 16:19:57 CST"
> Warning message:
> Incompatible methods ("+.POSIXt", "Ops.difftime") for "+"
> 
> "+.POSIXt" does behave as expected, though:
> 
>  > "+.POSIXt"(x,as.difftime("1","%H"))
> [1] "2007-02-21 17:19:56 CST"
> 
>  > R.version
>                 _
> platform       i686-pc-linux-gnu
> arch           i686
> os             linux-gnu
> system         i686, linux-gnu
> status         Under development (unstable)
> major          2
> minor          5.0
> year           2007
> month          01
> day            07
> svn rev        40398
> language       R
> version.string R version 2.5.0 Under development (unstable) (2007-01-07 
> r40398)

Oops! I thought I ran this on the latest revision, but the same behavior 
is exhibited in r40774:

 > x <- Sys.time()
 > x
[1] "2007-02-21 16:44:16 CST"
 > x + as.difftime("1","%H")
[1] "2007-02-21 16:44:17 CST"
Warning message:
Incompatible methods ("+.POSIXt", "Ops.difftime") for "+"
 > R.version
                _
platform       i686-pc-linux-gnu
arch           i686
os             linux-gnu
system         i686, linux-gnu
status         Under development (unstable)
major          2
minor          5.0
year           2007
month          02
day            21
svn rev        40774
language       R
version.string R version 2.5.0 Under development (unstable) (2007-02-21 
r40774)


Jeff
-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner



[Rd] Adding difftime objects to POSIXt objects
Jeffrey Horner