Modifying the invalid times 14:62:11 and 14:68:11 to other values try the following:
Lines1 <- "x y 14:56:10 0.325 14:57:11 0.111 14:58:11 0.214 16:05:18 0.245 16:11:09 0.266 16:17:05 0.271 16:33:00 0.304 16:39:05 0.300" Lines2 <- "x y 15:59:08 0.255 16:05:44 0.281 16:11:25 0.249 16:17:39 0.238 16:23:51 0.288" library(zoo) library(chron) z1 <- read.zoo(textConnection(Lines1), header = TRUE, FUN = times) z2 <- read.zoo(textConnection(Lines2), header = TRUE, FUN = times) z <- merge(z1, z2) # use merge(z1, z2, ..., zn) if you have n of these zoo(rowMeans(z, na.rm = TRUE), time(z)) On 6/6/06, Randy Zelick <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to average a number of data sets where the x vector contains > times and the Y data are instrument readings. The vectors all have > different numbers of values, but many X time values match. For example: > > A fragment of the first data set: > > x vect value > 14:56:10 0.325 > 14:62:11 0.111 > 14:68:11 0.214 > . > . > . > this can go on for 100's of values, spaced by 6 minutes, but there can be > gaps too, like: > > 16:05:18 0.245 > 16:11:09 0.266 > 16:17:05 0.271 > 16:33:00 0.304 > 16:39:05 0.300 > > > A fragment of the second data set: > > 15:59:08 0.255 > 16:05:44 0.281 > 16:11:25 0.249 > 16:17:39 0.238 > 16:23:51 0.288 > > > ...and the result I am looking for is a new vector that looks like this: > > 14:56:10 0.325 > 14:62:11 0.111 > 14:68:11 0.214 > . > . > . > 15:59:08 0.255 > 16:05:18 0.2630 * matches, so average > 16:11:09 0.2575 * matches, so average > 16:17:05 0.2545 * matches, so average > 16:33:00 0.304 > 16:39:05 0.300 > > > The times values in the new X vector are properly interleaved taking data > across the datasets, but when there is a match the Y values are averaged. > Note that the seconds don't matter. > > I am using R Version 2.2.1 on a PC > > Thanks for thinking about it, > > =Randy= > > R. Zelick email: [EMAIL PROTECTED] > Department of Biology voice: 503-725-3086 > Portland State University fax: 503-725-3888 > > mailing: > P.O. Box 751 > Portland, OR 97207 > > shipping: > 1719 SW 10th Ave, Room 246 > Portland, OR 97201 > > ______________________________________________ > 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 > ______________________________________________ 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