Displaying 20 results from an estimated 4000 matches similar to: "Adding difftime objects to POSIXt objects"
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
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
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:
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"
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
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
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 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
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,
2009 Nov 19
0
In the documentation of 'Ops.Date', please remove mention about "difftime", like in the documentation of 'DateTimeClasses' (PR#14072)
I am sorry to reply. But I need to clarify things.=0A=0AFrom searching over=
the internet, I know that, before R 2.5.0, in the documentation of 'DateTi=
meClasses', in 'date + x', in the explanation about 'x', there is also ment=
ion that 'x' can be a 'difftime' object. Now, it has been removed.=0A=0AWhy=
not doing the same in the documentation of
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
2007 Dec 14
3
How to convert Datetime numbers from Excel to POSIXt objects
Hi all,
I need to compare time series data files of different time formats. I
had no problems with text format using strptime.
But how can I convert datetime numbers from Excel (days since 30.12.1899
00:00:00) into POSIXt objects?
For example 29770.375 should be converted to "03.07.1981 09:00:00"
I tried the following code and encountered strange results:
t1-t0 gives 29770.33
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
2001 Nov 26
3
Doing things with POSIXt
Dear R-Users,
I have a data file with timestamps and I wanted to use POSIXct time data
type to represent the respective column. I played around with the type and
found a couple of issues:
* there seems to be no direct way of reading datetimes into a variable.
Let's say this is my file
"1992-02-27 23:03:20 PST"
"1992-02-27 22:29:56 PST"
"1992-01-14 01:03:30 PST"
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
2003 Dec 04
5
Processing calendar dates with R
I am a beginner in R with a background in SAS.
Are there built-in R methods of reading dates for calculating elapsed days
between two calendar dates? If so, are there any examples I can browse?
Thanks in anticipation.
John Byrne.
Lecturer in Information Systems.
Australian Catholic University.
2007 Feb 23
0
Formatting difftime objects
I like the new difftime functionality. Here's a dataframe of 5k run times:
> r5k
race date totaltime pace mile
1 RUDOLPH 2004-12-03 19:00:00 27.76667 mins 8.937224 mins 3.106856
2 RUDOLPH 2005-12-02 18:30:00 25.28333 mins 8.137916 mins 3.106856
3 FROSTBITE 2005-12-10 07:00:00 24.75000 mins 7.966253 mins 3.106856
4 JUDICATA 2006-03-04
2011 Feb 14
3
how to order POSIXt objects ?
I have a problem ordering by descending magnitude a POSIXt object. Can
someone help please and let me know how to work around this. My goal is to
be able to order my data by DATE and then by descending TIME.
I have tried to include as much info as possible below. The problem stems
from trying to read in times from a CSV file. I have converted the character
time values to a POSIXt object using the