Displaying 20 results from an estimated 10000 matches similar to: "Operations on difftime (abs, /, c)"
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 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
2009 Feb 17
0
Problem with +(POSIXt, difftime) dispatching -- WAS: How to create sequence of constant time interval
There seems to be a problem in the way `+` is dispatched for
POSIXt/difftime (R 2.8.0 Windows).
With the following definitions:
t0 <- as.POSIXct('2009-01-01 00:00')
halfhour.mins <- as.difftime(30,units='mins')
I would have thought that the straightforward answer to Suresh's
question would be something like
t0 + halfhour.mins * (0:47)
And indeed, if we
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
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 <-
2011 Aug 14
2
Trouble: Time Difference with difftime
Hello all!!!
I want to measure the duration of events (given a start and an end time).
The catch is that I require the output in calender days. This means:
02-Jan-2011 00:01:00 minus 01-Jan-2011 23:59:00 should be 1 day (although
the real time difference is only 2 minutes)
My data is the following
head(episode.ct)
[1] "2009-07-13 13:37:20 CEST" "2009-07-14 07:29:20 CEST"
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",
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
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
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]
2005 Nov 23
3
date/time arithmetic
On the help page "DateTimeClasses {base}" it says:
"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."
However,
> x<-Sys.time(); y<-Sys.time()+3600
> diff<-y-x
> x; y; diff
[1] "2005-11-23 19:58:20 GMT"
[1] "2005-11-23 20:58:20 GMT"
Time difference of 1 hours
2002 Oct 17
4
Posix Problem, difftime
I am having a series of problems using date time data that has been converted into a POSIXt and POSIXlt classes. I have hourly time series data from 1900 that has been converted from text data.
I assume most of my problems come from a mis-underdanding of the POSIX class. My matrix named (aa) for this year is approx 8700 by 4. When I try to calculate the length of posit column ( which is the
2008 Dec 09
3
difftime
Hi. I'm trying to take the difference in days between two times. Can
you point out what's wrong, or suggest a different function? When I
try the following code, The following code works fine:
a <- strptime(1911100807,format="%Y%m%d%H",tz="GMT")
b <- strptime(1911102718,format="%Y%m%d%H",tz="GMT")
x <- difftime(b, a,
2008 May 21
3
Converting a 'difftime' to integer - How to???
I want to find the DOY (Day of Year) of some dates. I think to substract the date 1. January from the data to achive this. Something like:
> d <- as.Date("2006-03-13") - as.Date("2006-01-01") +1
> d
Time difference of 72 days
So far so good. But d is a 'difftime' object. How do I get an Integer value from that?
I tried severel things, incuding the
2003 Apr 27
2
Basic date time arithmetics operations
Hello,
For basic date time arithmetics operations, AFAK, there're
actually the function difftime() and the (dt + num) operations.
I'm wondering if other basic operations exist, like
add(dt, num, unit) where unit would be "y", "q", "m", etc.
Also for the function seq.dates (or seq.POSIXt), the
case for by="months" would be more useful if it
2003 Apr 27
2
Basic date time arithmetics operations
Hello,
For basic date time arithmetics operations, AFAK, there're
actually the function difftime() and the (dt + num) operations.
I'm wondering if other basic operations exist, like
add(dt, num, unit) where unit would be "y", "q", "m", etc.
Also for the function seq.dates (or seq.POSIXt), the
case for by="months" would be more useful if it
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 object)
simply turns off the units
2011 Oct 19
1
Square ended segments
Good Afternoon R Community,
I am working on plotting behavior codes over short durations of time (a few seconds at a time over 1-2 hrs). I am utilizing as.POSIXct to store the time. I wanted to make a quasi time line using these time. I utilized the segments function to represent these times. However the segments rounds off at the ends and does not have the crisp look I need for my purposes.
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 Jan 12
0
Wishlist: Function 'difftime' to honor 'tzone' attribute (PR#14182)
Full_Name: Suharto Anggono
Version: 2.8.1
OS: Windows
Submission from: (NULL) (125.165.84.118)
PR#14076 inspired me to write this.
> t1 <- as.POSIXct("1970-01-01 00:00:00", tz="GMT")
> t2 <- as.POSIXlt("1970-01-01 00:00:00", tz="GMT")
> t1 - t2
Time difference of 7 hours
Above, t1 and t2 represent the same time in the same specified