[R] Computing time differences

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jun 20 13:14:37 CEST 2007


Try this and see the help desk article in R News 4/1:

> x <- 20080620.00
> x2 <- 20090218.00
> num2Date <- function(x) as.Date(paste(x), "%Y%m%d")
> num2Date(x2) - num2Date(x)
Time difference of 243 days
> as.numeric(num2Date(x2) - num2Date(x))
[1] 243

On 6/20/07, vincent.duval at boehringer-ingelheim.com
<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.
>



More information about the R-help mailing list