Try this: > library(zoo) > # create two time series to test with > z1 <- zooreg(0:10, Sys.Date()) > z2 <- lag(z1, 5) > > z1 2008-10-02 2008-10-03 2008-10-04 2008-10-05 2008-10-06 2008-10-07 2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12 0 1 2 3 4 5 6 7 8 9 10 > z2 2008-09-27 2008-09-28 2008-09-29 2008-09-30 2008-10-01 2008-10-02 2008-10-03 2008-10-04 2008-10-05 2008-10-06 2008-10-07 0 1 2 3 4 5 6 7 8 9 10 > > # intersect them > merge(z1, z2, all = FALSE) z1 z2 2008-10-02 0 5 2008-10-03 1 6 2008-10-04 2 7 2008-10-05 3 8 2008-10-06 4 9 2008-10-07 5 10 > range(time(merge(z1, z2, all = FALSE))) [1] "2008-10-02" "2008-10-07"
On Wed, Oct 1, 2008 at 12:48 PM, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > Hi all, > > Please, how could I calculate the time that two time segments has in common? > Is there any function to perform this calculation? > > For instance, given four POSIXlt objects... > > endPeriod<-as.POSIXlt("2008-09-30") > startPeriod<-as.POSIXlt("2007-10-01") > endProject<-as.POSIXlt("2007-05-31") > startProject<-as.POSIXlt("2006-12-01") > > that limit two time segments... > > project <- as.numeric(endProject-startProject) > period <- as.numeric(endPeriod-startPeriod) > > How could I calculate the time project and period overlap? > > Thanks for your help! > > Ricardo > > > > -- > Ricardo RodrÃguez > Your XEN ICT Team > > ______________________________________________ > R-help@r-project.org 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@r-project.org 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.