On Jun 23, 2009, at 9:50 AM, Gabor Grothendieck wrote:
Your zoo object is illegal since zoo objects are not supposed to
have duplicated times;
They were unique at the sub-second level.
however, ignoring that if the object has
at most one NA in each row, which is the case in the example,
then this will produce a numeric vector and you can create a
new zoo object out of that:
rowSums(z, na.rm = TRUE)
[1] 1.63755 1.63760 1.63760 1.63755 1.63755 1.63760
But that will not give the desired answer if both aq$mid and d2$mid
were present at the same time.
On Tue, Jun 23, 2009 at 9:29 AM, <rory.wins...@gmail.com> wrote:
Hi
I have two irregular time series, which are of different lengths
and being
and end at different times. For the common subset of time that they
both
span, they should have the same values, but the values may occur at
slightly different time intervals. I am trying to "line up" the
identical
values and reconcile them. I have merged the two series into a zoo
object
which looks like the following:
head(m)
aq$mid d2$mid
2009-06-22 16:25:40.044 NA 1.63755
2009-06-22 16:25:40.909 1.63760 NA
2009-06-22 16:25:40.987 NA 1.63760
2009-06-22 16:25:41.657 1.63755 NA
2009-06-22 16:25:41.738 NA 1.63755
2009-06-22 16:25:41.909 1.63760 NA
What I would like to do is merge the series column-wise : ie where
one
column contains NAs, replace the NAs with the non-NA value from the
other
column. Is this possible easily?
Here is a dput() of the data above:
structure(c(NA, 1.6376, NA, 1.63755, NA, 1.6376, 1.63755, NA,
1.6376, NA, 1.63755, NA), .Dim = c(6L, 2L), .Dimnames = list(
NULL, c("aq$mid", "d2$mid")), index = structure(c(1245684340.044,
1245684340.909, 1245684340.987, 1245684341.657, 1245684341.738,
1245684341.909), class = c("POSIXt", "POSIXct")), class = "zoo")
Cheers
-- Rory
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
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.