[R] Merge failure using zoo package

e-letter inpost at gmail.com
Fri Apr 2 16:55:49 CEST 2010


Readers,

Please refer to attached example data files. It seems that the merge
function fails for the latter section of the data set. Command
terminal output:

> library(chron)
> library(zoo)
> x<-read.zoo("test1.csv",header=TRUE,sep=",",FUN=times)
> y<-read.zoo("test2.csv",header=TRUE,sep=",",FUN=times)
> z<-(na.approx(merge(x[,2],y[,2]),time(z1)))
> z
            x[, 2]    y[, 2]
01:01:01 0.5418645 0.1755847
01:01:30 0.3486081 0.2068249
01:01:42 0.4808362 0.2380651
01:02:00 0.6130642 0.4983712
01:02:23 0.3140116 0.7586773
01:19:00 0.8545863 0.8927112
01:24:00 0.9555565 0.1490374

To overcome this behaviour the files test3 and test4 were created by
removing data that had been merged previously. Command terminal output
below:

> x<-read.zoo("test3.csv",header=TRUE,sep=",",FUN=times)
> y<-read.zoo("test4.csv",header=TRUE,sep=",",FUN=times)
> z<-(na.approx(merge(x[,2],y[,2]),time(z1)))
> z
            x[, 2]    y[, 2]
01:03:06 0.4827475 0.7350236
01:03:30 0.6951390 0.8376028
01:03:50 0.5798283 0.9401821
01:04:00 0.4645176 0.8330635
01:04:30 0.6167257 0.7259450
01:19:00 0.8545863 0.8927112
01:24:00 0.9555565 0.1490374

The only way to obtain a more complete merge of the data sets is to
create manually new files where previously merged data is removed and
then put all the merged data into a new file. Surely this package
should merge the data sets completely?

yours,

rhelp at conference.jabber.org
r251
mandriva2008


More information about the R-help mailing list