[R] Computing time differences
Stephen Tucker
brown_emu at yahoo.com
Wed Jun 20 16:46:50 CEST 2007
Here is one way:
Vector1 <- c("20080621.00","20080623.00")
Vector2 <- c("20080620.00","20080622.00")
do.call(difftime,
c(apply(cbind(time1=Vector1,time2=Vector2),2,
function(x) strptime(x,format="%Y%m%d.00")),
units="hours"))
see ?strptime, ?difftime and
http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf
--- vincent.duval at boehringer-ingelheim.com wrote:
> Dear R users,
>
> I have a problem computing time differences using R.
>
> I have a date that are given using the following format: 20080620.00, where
> the 4 first digits represent the year, the next 2 ones the month and the
> last
> 2 ones the day. I would need to compute time differences between two
> vectors
> of this given format.
>
> I tried around trying to change this format into any type of time serie
> without any succes.
>
> Could some one provide me with some useful suggestion and/or tip to know
> where to look?
>
> I am using R-2.4.0 under Windows XP
>
> Thanks for your help,
>
> Vincent
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
More information about the R-help
mailing list