[R] time segments intersection

[Ricardo Rodriguez] Your XEN ICT Team webmaster at xen.net
Fri Oct 3 00:53:32 CEST 2008

Hi John,

John Kane wrote:
> help("%in%") may be of use. However I don't see any overlap in your example.
You are right! I've choosen an example where the intersection is 0. But we could consider this other case...


project <- as.numeric(endProject-startProject)
period <- as.numeric(endPeriod-startPeriod)

I see how to use intersect with numbers as in the example:


%in% returns a logical vector indicating if there is a match or not, thus it is not an option for us.

*Please, how could I pass the date in seconds to intersect?*

I know how to  get system time in seconds, unclass(Sys.time()), but how could I get endPeriod, startPeriod and so on, so forth, to pass this values to intersect? It is the only way I can figure out to get a vector with the intersecting period. It will be a huge vector in some cases, but I guess I could get its size in anyway and to avoid to print out the values.

Thanks for your help,


Ricardo Rodríguez
Your XEN ICT Team

More information about the R-help mailing list