[R] Computing time differences
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))
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,
> [[alternative HTML version deleted]]
> R-help at stat.math.ethz.ch mailing list
> 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