Displaying 20 results from an estimated 3000 matches similar to: "difftime arithmetic (PR#2345)"
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:
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:
2009 Nov 16
0
(Date + difftime) and (POSIXt + difftime) does not use date/time arithmetics (PR#14067)
Full_Name: Suharto Anggono
Version: 2.8.1
OS: Windows
Submission from: (NULL) (125.165.81.48)
There is already PR#13369. But, the problem is not just the warning.
C:\Program Files\R\R-2.8.1\bin>R --vanilla
R version 2.8.1 (2008-12-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome
2010 Feb 11
2
difftime result for days not an integer?
Anybody have an idea why I would get a non-integer value for the
number of days here?
> difftime('2004-08-05','2001-01-03',units='days')
Time difference of 1309.958 days
Would you just round off?
Best,
Jon
2009 May 22
2
Scope problem?
I've just spent today trying to fix a Heisenbug...
this function returns a linear interpolator function:
interpOne <- function(xl,yl){
f = function(data){
t = (data-min(xl))/(max(xl)-min(xl))
return(min(yl)+t*(max(yl)-min(yl)))
}
return(f)
}
> k=interpOne(c(0,1),c(4,5))
> k(0.5)
[1] 4.5
and this function uses the above to return a function that returns a
piece-wise
2009 Nov 27
1
Long execution time for quantile() and difftime objects (PR#14091)
Full_Name: Hong Ooi
Version: 2.10.0
OS: Windows XP
Submission from: (NULL) (203.110.235.1)
While trying to get summary statistics on a duration variable (the difference
between a start and end date), I ran into the following issue. Using summary or
quantile (which summary calls) on a difftime object takes an extremely long time
if the object is even moderately large.
A reproducible example:
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", units = "days")
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
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
2018 Aug 01
1
RFC: make as.difftime more consistent or convenient
Hello!
you, Emil 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
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")
> setMethod("+", c("foo",
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"
> # Now using difftime, this
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")
> u2
Time differences in mins
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 be
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
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
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
2008 May 14
1
Time differences (as.difftime?) issue
Dear all,
I have a vector generated using the function strptime:
> my.dt
[1] "2004-04-19 08:35:00 W. Europe Daylight Time" "2004-04-19 09:35:00 W.
Europe Daylight Time" "2004-04-19 11:35:00 W. Europe Daylight Time"
[4] "2004-04-19 13:35:00 W. Europe Daylight Time" "2004-04-20 07:50:00 W.
Europe Daylight Time"
> class(my.dt)
[1]
2009 Mar 17
1
Mean of difftime vectors : "code infelicity" or intended behaviour ?
Dear list,
"+" (and "-") being defined for difftime class, I expected mean() to
return something sensible. This is only half-true :
> mean(c(1:5, 5:1),na.rm=TRUE)
[1] 3
> mean(as.difftime(c(1:5, 5:1),unit="mins"),na.rm=TRUE)
Time difference of 3 mins
Fine so far. However :
> mean(c(1:5, NA,5:1),na.rm=TRUE)
[1] 3
> mean(as.difftime(c(1:5,
2012 Mar 19
1
diff(time) vs. difftime?
I just encountered another RTFM problem: With
diff(as.POSIXct(...), ...) I was unable to control the units of the
results. Examples:
> (d.d <- diff(as.POSIXct(c('2012-12-12', '2012-12-13'))))
Time difference of 1 days
> (d.h <- diff(as.POSIXct(c('2012-12-12 08:00', '2012-12-12 09:00'))))
Time difference of 1 hours
> (d.m <-