similar to: Converting a number of minutes to a difftime

Displaying 20 results from an estimated 40000 matches similar to: "Converting a number of minutes to a difftime"

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"
2008 Jan 27
1
bug in difftime with as.POSIXct
I am trying to do ephemeris calculations in R, which involves calculating an elapsed time. As illustrated below, difftime seems to have problems with my method, since the fractional day is sometimes the correct 0.5 and sometimes the incorrect 0.46. I am doing this on with R-2.6.1 on a powerpc-apple-darwin8.10.1 system. I get the same results for as.POSIXlt() instead of as.POSIXct(), but the
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 Sep 15
1
difftime on vector
How can I apply difftime to a vector of sorted dates? I can do this just fine with diff, but difftime doesn't seem to take in a vector. > diff(r$BOOKING_DATE) Works. Great! > difftime(r$MY_DATE, units="days") Error in as.POSIXct(time2) : argument "time2" is missing, with no default Thanks, Bradford [[alternative HTML version deleted]]
2006 Feb 21
3
Number of Days Between Dates: Incorrect Results For Date Calucations.
In some cases, incorrect results are produced by the code below intended to calculate the number of days between 2 dates. The year in question was a leap year. Note the results for 2004-04-04 and 2004-04-05 are the same! They should be 37 and 38 respectively. > as.integer(as.POSIXct("2004-04-02") - as.POSIXct("2004-02-27")) [1] 35 >
2006 Mar 15
2
difftime arguments
Hi I just started using RGui.exe under widnows. I have a text file containing date arranged in columns and rows, each column has the same format, each row with different formats. 3 of the columns are something like this 1/12/2006 3:59:45 PM I need to calculate the different in seconds between 2 selected periods using their row’s index My solution: Read the file in a data frame and
2008 Sep 19
1
Trouble with difftime()
Hello again, I'm interested in manipulating some date objects, and have been playing with the difftime function. I'm not sure that this is the desired behavior: > pa$days.before.apr30 <- difftime(may01,as.POSIXct(pa$training.max,origin=as.POSIXct("1969-12-31 16:00:00",tz="PDT")),units="days") > units(pa$days.before.apr30) [1] "days" >
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:
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]
2013 Feb 01
2
difftime() out by 1 hour
I have a problem with results from difftime being 1 hour different than expected. 2 examples are given below: datetime <- matrix(data=rbind(c("2012-03-31 21:00:00", "2012-04-01 00:00:00", "2012-04-01 03:00:00", "2012-04-01 06:00:00"), c("2012-10-06 21:00:00", "2012-10-07 00:00:00", "2012-10-07 03:00:00",
2011 Sep 19
2
fechas ??
Hola a todos: Tengo un problema con las fechas, básicamente necesito una diferencia en días y siempre se sale en segundos. Salvo un ejemplo copiado de un libro, pero yo necesito procesar los datos propios. Les paso el código en R (copiar y pegar, son solo dos días que se comparan) y al final como me salen los resultados porque es medio complicada mi redacción. ¿Alguna idea? fechas1
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
2009 Sep 11
1
What determines the unit of POSIXct differences?
Dear All, what determines if a difference between POSIXct objects gets expressed in days or seconds? In the following example, it's sometimes seconds, sometimes days. as.POSIXct('2009-09-01') - as.POSIXct(NA) Time difference of NA secs c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) - c(as.POSIXct('2009-09-01'), as.POSIXct('2009-08-31')) Time differences in
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.
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
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
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