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 <inp...@gmail.com> wrote:
>> library(chron)
>> library(zoo)
>> z1<-read.zoo("~/path/to/test1.csv",header=TRUE,sep=",",FUN=times)
>> z2<-read.zoo("~/path/to/test2.csv",header=TRUE,sep=",",FUN=times)
>> z3<-(na.approx(merge(z1,z2),time(z1)))
> Error in approx(along[!na], y[!na], along[na], ...) :
>        need at least two non-NA values to interpolate
>> z3<-(na.approx(merge(z1,z2[,2]),time(z1)))
> Error in approx(along[!na], y[!na], along[na], ...) :
>        need at least two non-NA values to interpolate
>> z3<-(na.approx(merge(z1,z2[,3]),time(z1)))
> Error in `[.zoo`(z2, , 3) : subscript out of bounds
>> z4<-read.zoo(textConnection(z2),FUN=times)
> Error in textConnection(z2) : invalid 'text' argument
>

______________________________________________
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.

Reply via email to