On Tue, 13 Jun 2006 18:49:09 -0700, Spencer Graves <[EMAIL PROTECTED]> wrote:
> Did you try the following: > >> xto-xfrom > Time in days: > [1] 1.50 1.75 2.00 2.25 > Also, have you seen Gabor Grothendieck and Thomas Petzoldt. "R help desk: Date and time classes in R". R News, 4(1):29-32, June 2004., downloadable from www.r-project.org -> "Documentation: Newsletter" as well as the "zoo" vignette (see "http://finzi.psych.upenn.edu/R/Rhelp02a/archive/67006.html")? > > hope this helps. > Spencer Graves > > Sebastian Luque wrote: >> 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, >> -- Sebastian P. Luque Current address: Department of Biology Fisheries and Oceans Canada Memorial University of Newfoundland 501 University Crescent [EMAIL PROTECTED] Winnipeg, MB R3T 2N6, Canada http://sebmags.homelinux.org/~sluque Tel +1 204 586-8170, Fax ... 984-2403 ______________________________________________ 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