[R] Merge failure using zoo package

e-letter inpost at gmail.com
Wed Apr 7 12:41:04 CEST 2010


I tried your instructions, as shown.

> library(chron)
> library(zoo)
> z1<-read.zoo("test1.csv",header=TRUE,sep=",",FUN=times)
> z2<-read.zoo("test2.csv",header=TRUE,sep=",",FUN=times)
> z12<-merge(z1,z2)
> z3<-na.approx(z12,xout=time(z1))
Error in approx(along[!na], y[!na], along[na], ...) :
        invalid interpolation method
In addition: Warning message:
the condition has length > 1 and only the first element will be used
in: if (is.na(method)) stop("invalid interpolation method")
> source("http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/zoo/R/na.approx.R?rev=676&root=zoo")
> z3<-na.approx(z12,xout=time(z1))
> z3
                 z1         z2
01:01:30 0.34860813 0.21977817
01:02:00 0.61306418 0.46662656
01:02:30 0.01495898 0.75482666
01:03:00 0.27035612 0.73832408
...

It looks that the data of z3 shows only values corresponding to times
in z1. In the previous merge, z3 consisted of values for times in both
z1 and z2, e.g.:

            z1[, 2]    z2[, 2]
01:01:01 0.54186455 0.17558467
01:01:30 0.34860813 0.20682491
01:01:42 0.48083615 0.23806514
01:02:00 0.61306418 0.49837120

With respect to advice about seeking help, I think it would be very
good if your comments about using the command 'textConnection()' were
added to the FAQ section or the posting guide, to help novices improve
the quality of asking for help.



More information about the R-help mailing list