[R] Merge failure using zoo package
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Apr 2 17:20:28 CEST 2010
The files only have one data column. What is the meaning of x[,2],
etc. ? What is z1?
Please provide reproducible code and data all in a single file using
this style so its clear what is what. Also please cut down the size of
your data to the smallest size that will still illustrate the problem.
Lines1 <- "a,b
1,2
3,4"
library(zoo)
library(chron)
z1 <- read.zoo(textConnection(Lines1), header = TRUE, sep = ",", FUN = ...)
etc.
On Fri, Apr 2, 2010 at 10:55 AM, e-letter <inpost at gmail.com> wrote:
> 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
>
> ______________________________________________
> R-help at 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.
>
>
More information about the R-help
mailing list