Re: [R] Computing time differences

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed, 20 Jun 2007 07:14:37 -0400

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.
>



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. Received on Wed 20 Jun 2007 - 11:31:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Jun 2007 - 12:32:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.