search for: difftim

Displaying 20 results from an estimated 312 matches for "difftim".

Did you mean: difftime
2009 Nov 16
0
(Date + difftime) and (POSIXt + difftime) does not use date/time arithmetics (PR#14067)
...re information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > as.Date("2009-09-15") + as.difftime(8, units="weeks") [1] "2009-09-23" Warning message: Incompatible methods ("+.Date", "Ops.difftime") for "+" I expect to get the date 8 weeks after 2009-09-15, but I get 8 days after 2009-09-15. To get the date 8 weeks after 2009-09-15, I have to...
2009 Feb 06
1
Operations on difftime (abs, /, c)
Since both comparison and negation are well-defined for time differences, I wonder why abs and division are not defined for class difftime. This behavior is clearly documented on the man page: "limited arithmetic is available on 'difftime' objects"; but why? Both are natural, semantically sound, and useful operations and I see no obvious reason that they should give an error: sec <- as.difftime(-3:3,units=&...
2009 Feb 06
1
Operations on difftime (abs, /, c)
Since both comparison and negation are well-defined for time differences, I wonder why abs and division are not defined for class difftime. This behavior is clearly documented on the man page: "limited arithmetic is available on 'difftime' objects"; but why? Both are natural, semantically sound, and useful operations and I see no obvious reason that they should give an error: sec <- as.difftime(-3:3,units=&...
2006 Apr 03
1
weird "max" behavior for difftime class
If you apply the "max" function to a vector of class "difftime" with units="days", the returned value is in units of "seconds". Is this not a bug? At any rate it can lead to confusing results if one buries a call to "max" deep in some data analysis code. Details: > y<-structure(1, class = "difftime", unit...
2009 Nov 19
0
Wishlist: In documentation, say that `+.Date`(Date, difftime) should be called directly or remove 'or an object of class "difftime"' (PR#14072)
Full_Name: Suharto Anggono Version: 2.8.1 OS: Windows Submission from: (NULL) (125.161.134.206) About PR#14067, now I understand why (Date + difftime) does not use '+.Date'. But, before I understand, it was surprising. The surprise is also reflected in the post "Problem with +(POSIXt, difftime) dispatching -- WAS: How to create sequence of constant time interval" in R-help 2009-02-17. This is taken from the documentation of O...
2007 Mar 22
2
R difftime function: How can we fix the difftime unit?
Hi, I am trying to take difference of two time objects. I want to fix the result's unit to minutes. How can I do that? Here is an example: > difftime(x, y) Time difference of 2.030720 hours > difftime(x, z) Time difference of 30.34672 mins where x = '2007-03-05 08:32:58' y = '2007-03-05 06:31:07' and z = '2007-03-05 08:02:37' How can I get answer something like for (x-y) Time difference of 121.8432 min...
2010 Jun 22
1
New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
On Thu, Jun 10, 2010 at 3:39 PM, Gustaf Rydevik <gustaf.rydevik at gmail.com> wrote: > Hi all, > > The recent change in 2.11 that made as.numeric() return false on > difftime-objects broke some of my code that calculated age classes of > individuals using cut(). While this was no big thing to fix for me, it > might be wise > to provide a cut.difftime method to ?stop other old code from breaking. > I'm guessing something as simple as > > cut.diffti...
2010 Jun 22
1
New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
On Thu, Jun 10, 2010 at 3:39 PM, Gustaf Rydevik <gustaf.rydevik at gmail.com> wrote: > Hi all, > > The recent change in 2.11 that made as.numeric() return false on > difftime-objects broke some of my code that calculated age classes of > individuals using cut(). While this was no big thing to fix for me, it > might be wise > to provide a cut.difftime method to ?stop other old code from breaking. > I'm guessing something as simple as > > cut.diffti...
2018 Aug 01
1
RFC: make as.difftime more consistent or convenient
...Bode <emil.bode at dans.knaw.nl>, wrote on Tuesday, July 31, 2018 1:55 PM: > Some of the changes you're proposing could be made (with effort), but note that you're not > restricted to providing strings with a format. > What you're trying to do can be accomplished with as.difftime(12, units='weeks'), see also > ?as.difftime > > Or if you're stuck with the strings: as.difftime(as.numeric(substring('12 w', 1, 2)), > units='weeks') > That also seems clearer, because in your script, the last part of your string simply gets > ignored...
2013 Jul 09
1
Is difftime a "class"
I am trying to write S4 methods with "difftime" in the signature but am being "informed" (? not a warning or error) that "difftime" is not a class. Nevertheless, dispatch takes place. Should I simply ignore that "information"? Here is a toy example: > setClass("foo", contains = "Date")...
2011 Oct 25
2
difftime producing NA values in R 2.12.2
R-listers, I have noticed several posts on issues with difftime producing NA's but they have been for older versions of R. Here's the issue associated with difftime that I am dealing with in R 2.12.2. > preciptime = strptime("01/10/2007 14:00",format="%m/%d/%Y %H:%M") > class(preciptime) [1] "POSIXlt" "POSIXt&...
2002 Dec 04
2
difftime arithmetic (PR#2345)
Full_Name: Barry Rowlingson Version: 1.6.0 OS: RH8 i386 Submission from: (NULL) (148.88.136.205) Strange things happen if I premultiply a difftime() object with a number. Example: > d1 <- difftime(Sys.time(),Sys.time()) > d2 <- 1 * difftime(Sys.time(),Sys.time()) > d3 <- difftime(Sys.time(),Sys.time()) * 1 > d1 Time difference of 0 secs - thats fine > d2 [1] 0 attr(,"units") [1] "secs" attr...
2009 Sep 25
1
Collision between difftime and ggplot2.
It seems that there are several folks Out There with an itch to scratch with respect to difftimes. http://article.gmane.org/gmane.comp.lang.r.devel/19223/match=difftime http://article.gmane.org/gmane.comp.lang.r.devel/18441/match=difftime http://article.gmane.org/gmane.comp.lang.r.devel/10882/match=difftime http://article.gmane.org/gmane.comp.lang.r.devel/11675/match=difftime and I might...
2010 Apr 05
1
using difftime()
I'm new to R and have the following problem with difftime: if I directly assign date/time strings in difftime I get the expected result: > a<-"2010-03-23 10:52:00" > a [1] "2010-03-23 10:52:00" > b<-"2010-03-23 11:53:00" > u2<-as.difftime(c(a,b), format ="%Y-%m-%d %H:%M:%S", units="mins&...
2007 Feb 21
1
Adding difftime objects to POSIXt objects
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:...
2005 Apr 30
3
as.numeric method for objects of class "difftime"
I have just become painfully aware that objects of class "difftime", generated by the difference of two POSIXct objects, carry a "units" attribute, which flashes by when the object is printed, for example. The pain was occasioned when I tried to turn these objects into numberic objects for use elsewhere as a covariate. as.numeric(difftime objec...
2018 Jul 31
0
RFC: make as.difftime more consistent or convenient
Hello! I notice I can convert strings containing hour, minute or second specifications to a 'difftime': > as.difftime("12 h", "%H") Time difference of 12 hours > as.difftime("12 m", "%M") Time difference of 12 mins > as.difftime("12 s", "%S") Time difference of 12 secs But I can't do so with a week specification, becaus...
2007 Oct 08
2
Incompatible methods ("-.POSIXt", "Ops.difftime") for "-"
Dear all, according to the Help-page of DateTimeClasses {base} I should be able to do time - z with time date-time objects z a numeric vector (in seconds) or an object of class "difftime". However, on R version 2.6.0 (Windows XP) I get > Sys.time() - as.difftime(c("0:3:20", "11:23:15")) Time differences in mins [1] 1191837998 1191837318 attr(,"tzone") [1] "" Warning message: Incompatible methods ("-.POSIXt", "Ops.diff...
2008 May 14
1
Time differences (as.difftime?) issue
..."POSIXt" "POSIXct" Now I would like to test if the difference from the times to the first time is lower than a given threshold: > my.dt - my.dt[1] < threshold The issue is, I would like to specificy the threshold as flexibly as possible, and I tried to do this using as.difftime > as.difftime(23, '%H') Time difference of 23 hours However, I cannot specify a threshold larger than 23 hours in units of hours: > as.difftime(24, '%H') Time difference of NA secs I can hack around this in the following way: > threshold <- as.difftime(23, '%H'...
2012 Mar 19
1
diff(time) vs. difftime?
...difference of 1 secs > as.numeric(d.d) [1] 1 > as.numeric(d.s) [1] 1 methods('diff') identified the following: [1] diff.Date diff.default diff.POSIXt diff.ts diff.zoo* In looking at the help pages for each of these functions, I found no mention of "difftime" or any other way to control the units. methods('-') [1] -.Date -.POSIXt -.yearmon* -.yearqtr* ?"-.Date" didn't seem helpful on this, either. ?"-.POSIXt" contained a link to "difftime", but I didn't see that until after I rea...