Skip to content
Prev 208135 / 398502 Next

use zoo package with multiple column data sets

Its a bug.  Its now fixed it in the development source so try this:

library(chron)

library(zoo)
source("http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/zoo/R/na.approx.R?rev=653&root=zoo")
source("http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/zoo/R/zoo.R?rev=653&root=zoo")

z1 <-
structure(1:4, index = structure(c(0.0423611111111111, 0.0428819444444444,
0.0434027777777778, 0.0439236111111111), format = "h:m:s", class =
"times"), class = "zoo")

z2 <-
structure(c(11L, 22L, 33L, 44L, 55L, 66L, 77L, 88L), .Dim = c(4L,
2L), .Dimnames = list(NULL, c("data", "data.1")), index =
structure(c(0.0423726851851852,
0.0424074074074074, 0.0424421296296296, 0.0424768518518518), format =
"h:m:s", class = "times"), class = "zoo")

out1 <- na.approx(merge(z1, z2), time(z1)); out1
out2 <- na.approx(merge(z1, z2), time(z1), na.rm = FALSE); out2
out3 <- na.approx(merge(z1, z2), time(z1), rule = 2); out3
out4 <- na.approx(merge(z1, z2)); out4
out5 <- na.approx(merge(z1, z2), na.rm = FALSE); out5
out6 <- na.approx(merge(z1, z2), rule = 2); out6

The above style (which uses the output of dput to form z1 and z2) or
the style requested in my last response using textConnection allows
one to copy and paste directly into one's session (rather than having
to download two files, copying and pasting to an editor, editing the
paths and finally copying and pasting to R).
On Sat, Jan 30, 2010 at 6:08 AM, e-letter <inpost at gmail.com> wrote: