Hi,

Say we have two chron vectors representing start and end date/times of an
event, respectively:


R> (xfrom <- chron(seq(1.25, 11, 3.25)))
[1] (01/02/70 06:00:00) (01/05/70 12:00:00) (01/08/70 18:00:00)
[4] (01/12/70 00:00:00)
R> (xto <- chron(as.numeric(xfrom) + seq(1.5, 2.25, 0.25)))
[1] (01/03/70 18:00:00) (01/07/70 06:00:00) (01/10/70 18:00:00)
[4] (01/14/70 06:00:00)


and we would like to know how much time is included in a number of
intervals within each event.  We can define the intervals with two chron
vectors:


R> (xt0 <- times(c(0.50, 0)))
[1] 12:00:00 00:00:00
R> (xt1 <- times(c(1 - (1 / 86400), 0.25)))
[1] 23:59:59 06:00:00


So for the first event, 01/02/70 06:00:00 to 01/03/70 18:00:00, the
interest is to find how much time corresponds to periods 12:00:00 -
23:59:59 and 00:00:00 - 06:00:00.

I began writing a function to accomplish this task, but am at an impasse.
The archives may have something on this, but I haven't found a good search
query for it, so I'd appreciate some pointers.  Thanks in advance.


Cheers,

-- 
Seb

______________________________________________
R-help@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

Reply via email to