Re: [R] Merge failure using zoo package

2010-04-07 Thread e-letter
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=676root=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.

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


Re: [R] Merge failure using zoo package

2010-04-07 Thread Gabor Grothendieck
On Wed, Apr 7, 2010 at 6:41 AM, e-letter inp...@gmail.com wrote:
 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=676root=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

Yes, when xout is specified it says that the result should be
evaluated only at the times specified in xout. .  Read about the xout
argument of na.approx and approx at ?approx .

 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.


OK. I have attached the example in a self contained style and will
post something suggesting that the maintainers of the posting guide
incorporate it.

Lines1 - time1,dataset1
01:01:00,0.73512097
01:01:30,0.34860813
01:02:00,0.61306418
01:02:30,0.01495898
01:03:00,0.27035612
01:03:30,0.69513898
01:04:00,0.46451758
01:04:30,0.61672569
01:05:00,0.82496122
01:05:30,0.34766154
01:06:00,0.69618714
01:06:30,0.39035214
01:07:00,0.01680143
01:07:30,0.28576967
01:08:00,0.01205416
01:08:30,0.89637254
01:09:00,0.63147653
01:09:30,0.01522139
01:10:00,0.27661960
01:10:30,0.50974124
01:11:00,0.68141977
01:11:30,0.90725854
01:12:00,0.83823443
01:12:30,0.53360241
01:13:00,0.17769196
01:13:30,0.83438616
01:14:00,0.67248807
01:14:30,0.09991933
01:15:00,0.03334966
01:15:30,0.93292355
01:16:00,0.15990837
01:16:30,0.05354050
01:17:00,0.55281203
01:17:30,0.37845690
01:18:00,0.89051365
01:18:30,0.16674292
01:19:00,0.85458626
01:19:30,0.19278550
01:20:00,0.73240405
01:20:30,0.16417524
01:21:00,0.73878212
01:21:30,0.51790118
01:22:00,0.83076438
01:22:30,0.4704
01:23:00,0.02108640
01:23:30,0.82911053
01:24:00,0.9646
01:24:30,0.14493657
01:25:00,0.84422332
01:25:30,0.41589974
01:26:00,0.67606367
01:26:30,0.00606434
01:27:00,0.59951991
01:27:30,0.43949260

Lines2 - time2,dataset2
01:01:01,0.17558467
01:01:42,0.23806514
01:02:23,0.75867726
01:03:06,0.73502357
01:03:50,0.94018206
01:04:35,0.61882643
01:05:21,0.68417492
01:06:08,0.05744461
01:06:55,0.33344394
01:07:44,0.68752593
01:08:33,0.17270469
01:09:23,0.81522124
01:10:03,0.68304352
01:10:43,0.38774082
01:11:23,0.84176890
01:12:04,0.0936
01:12:44,0.13431965
01:13:25,0.92210721
01:14:06,0.33630635
01:14:47,0.56690294
01:15:29,0.09870816
01:16:11,0.77864105
01:16:53,0.61803441
01:17:35,0.09133728
01:18:17,0.08925487
01:19:00,0.89271117
01:19:42,0.56605742
01:20:25,0.98520534
01:21:08,0.66104843
01:21:51,0.96948589
01:22:34,0.05692690
01:23:17,0.71887456
01:24:00,0.14903741
01:24:43,0.86569445
01:25:26,0.27923513
01:26:09,0.98365033
01:26:53,0.08308399
01:27:36,0.87071027
01:28:19,0.26475705
01:29:03,0.76409811
01:29:47,0.59563256
01:30:31,0.23995054
01:31:14,0.00951054
01:31:59,0.21367270

library(chron)
library(zoo)
z1-read.zoo(textConnection(Lines1),header=TRUE,sep=,,FUN=times)
z2-read.zoo(textConnection(Lines2),header=TRUE,sep=,,FUN=times)
z12 - merge(z1, z2)
# 
source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/zoo/R/na.approx.R?rev=676root=zoo;)
z3-na.approx(z12,xout=time(z1))

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


Re: [R] Merge failure using zoo package

2010-04-02 Thread e-letter
Data files test1, ...2, ...3, ...4 respectively.

time1,dataset1
01:01:00,0.73512097
01:01:30,0.34860813
01:02:00,0.61306418
01:02:30,0.01495898
01:03:00,0.27035612
01:03:30,0.69513898
01:04:00,0.46451758
01:04:30,0.61672569
01:05:00,0.82496122
01:05:30,0.34766154
01:06:00,0.69618714
01:06:30,0.39035214
01:07:00,0.01680143
01:07:30,0.28576967
01:08:00,0.01205416
01:08:30,0.89637254
01:09:00,0.63147653
01:09:30,0.01522139
01:10:00,0.27661960
01:10:30,0.50974124
01:11:00,0.68141977
01:11:30,0.90725854
01:12:00,0.83823443
01:12:30,0.53360241
01:13:00,0.17769196
01:13:30,0.83438616
01:14:00,0.67248807
01:14:30,0.09991933
01:15:00,0.03334966
01:15:30,0.93292355
01:16:00,0.15990837
01:16:30,0.05354050
01:17:00,0.55281203
01:17:30,0.37845690
01:18:00,0.89051365
01:18:30,0.16674292
01:19:00,0.85458626
01:19:30,0.19278550
01:20:00,0.73240405
01:20:30,0.16417524
01:21:00,0.73878212
01:21:30,0.51790118
01:22:00,0.83076438
01:22:30,0.4704
01:23:00,0.02108640
01:23:30,0.82911053
01:24:00,0.9646
01:24:30,0.14493657
01:25:00,0.84422332
01:25:30,0.41589974
01:26:00,0.67606367
01:26:30,0.00606434
01:27:00,0.59951991
01:27:30,0.43949260
01:28:00,0.66297385
01:28:30,0.33131298
01:29:00,0.06102041
01:29:30,0.84722118
01:30:00,0.46841491
01:30:30,0.34200755
01:31:00,0.87386578
01:31:30,0.70737403
01:32:00,0.23978781
01:32:30,0.11787278
01:33:00,0.14679814
01:33:30,0.65217063
01:34:00,0.81355908
01:34:30,0.31583482
01:35:00,0.92167666
01:35:30,0.55931271
01:36:00,0.13641271
01:36:30,0.35048575
01:37:00,0.17243584
01:37:30,0.93645686
01:38:00,0.85356548
01:38:30,0.61399352
01:39:00,0.05910707
01:39:30,0.01721605
01:40:00,0.94845557
01:40:30,0.48117810
01:41:00,0.34752402
01:41:30,0.59295472
01:42:00,0.64267429
01:42:30,0.57859933
01:43:00,0.00201441
01:43:30,0.32530995
01:44:00,0.25474645
01:44:30,0.93187534
01:45:00,0.99361033
01:45:30,0.16591641

time2,dataset2
01:01:01,0.17558467
01:01:42,0.23806514
01:02:23,0.75867726
01:03:06,0.73502357
01:03:50,0.94018206
01:04:35,0.61882643
01:05:21,0.68417492
01:06:08,0.05744461
01:06:55,0.33344394
01:07:44,0.68752593
01:08:33,0.17270469
01:09:23,0.81522124
01:10:03,0.68304352
01:10:43,0.38774082
01:11:23,0.84176890
01:12:04,0.0936
01:12:44,0.13431965
01:13:25,0.92210721
01:14:06,0.33630635
01:14:47,0.56690294
01:15:29,0.09870816
01:16:11,0.77864105
01:16:53,0.61803441
01:17:35,0.09133728
01:18:17,0.08925487
01:19:00,0.89271117
01:19:42,0.56605742
01:20:25,0.98520534
01:21:08,0.66104843
01:21:51,0.96948589
01:22:34,0.05692690
01:23:17,0.71887456
01:24:00,0.14903741
01:24:43,0.86569445
01:25:26,0.27923513
01:26:09,0.98365033
01:26:53,0.08308399
01:27:36,0.87071027
01:28:19,0.26475705
01:29:03,0.76409811
01:29:47,0.59563256
01:30:31,0.23995054
01:31:14,0.00951054
01:31:59,0.21367270

time1,dataset1
01:02:30,0.01495898
01:03:00,0.27035612
01:03:30,0.69513898
01:04:00,0.46451758
01:04:30,0.61672569
01:05:00,0.82496122
01:05:30,0.34766154
01:06:00,0.69618714
01:06:30,0.39035214
01:07:00,0.01680143
01:07:30,0.28576967
01:08:00,0.01205416
01:08:30,0.89637254
01:09:00,0.63147653
01:09:30,0.01522139
01:10:00,0.27661960
01:10:30,0.50974124
01:11:00,0.68141977
01:11:30,0.90725854
01:12:00,0.83823443
01:12:30,0.53360241
01:13:00,0.17769196
01:13:30,0.83438616
01:14:00,0.67248807
01:14:30,0.09991933
01:15:00,0.03334966
01:15:30,0.93292355
01:16:00,0.15990837
01:16:30,0.05354050
01:17:00,0.55281203
01:17:30,0.37845690
01:18:00,0.89051365
01:18:30,0.16674292
01:19:00,0.85458626
01:19:30,0.19278550
01:20:00,0.73240405
01:20:30,0.16417524
01:21:00,0.73878212
01:21:30,0.51790118
01:22:00,0.83076438
01:22:30,0.4704
01:23:00,0.02108640
01:23:30,0.82911053
01:24:00,0.9646
01:24:30,0.14493657
01:25:00,0.84422332
01:25:30,0.41589974
01:26:00,0.67606367
01:26:30,0.00606434
01:27:00,0.59951991
01:27:30,0.43949260
01:28:00,0.66297385
01:28:30,0.33131298
01:29:00,0.06102041
01:29:30,0.84722118
01:30:00,0.46841491
01:30:30,0.34200755
01:31:00,0.87386578
01:31:30,0.70737403
01:32:00,0.23978781
01:32:30,0.11787278
01:33:00,0.14679814
01:33:30,0.65217063
01:34:00,0.81355908
01:34:30,0.31583482
01:35:00,0.92167666
01:35:30,0.55931271
01:36:00,0.13641271
01:36:30,0.35048575
01:37:00,0.17243584
01:37:30,0.93645686
01:38:00,0.85356548
01:38:30,0.61399352
01:39:00,0.05910707
01:39:30,0.01721605
01:40:00,0.94845557
01:40:30,0.48117810
01:41:00,0.34752402
01:41:30,0.59295472
01:42:00,0.64267429
01:42:30,0.57859933
01:43:00,0.00201441
01:43:30,0.32530995
01:44:00,0.25474645
01:44:30,0.93187534
01:45:00,0.99361033
01:45:30,0.16591641

time2,dataset2
01:03:06,0.73502357
01:03:50,0.94018206
01:04:35,0.61882643
01:05:21,0.68417492
01:06:08,0.05744461
01:06:55,0.33344394
01:07:44,0.68752593
01:08:33,0.17270469
01:09:23,0.81522124
01:10:03,0.68304352
01:10:43,0.38774082
01:11:23,0.84176890
01:12:04,0.0936
01:12:44,0.13431965
01:13:25,0.92210721
01:14:06,0.33630635
01:14:47,0.56690294
01:15:29,0.09870816
01:16:11,0.77864105
01:16:53,0.61803441
01:17:35,0.09133728
01:18:17,0.08925487
01:19:00,0.89271117

Re: [R] Merge failure using zoo package

2010-04-02 Thread Gabor Grothendieck
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 inp...@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.965 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.965 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,

 rh...@conference.jabber.org
 r251
 mandriva2008

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



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


Re: [R] Merge failure using zoo package

2010-04-02 Thread e-letter
On 02/04/2010, Gabor Grothendieck ggrothendi...@gmail.com wrote:
 The files only have one data column.  What is the meaning of x[,2],
 etc. ?   What is z1?

I only want to merge one column from one file with one column from
another file. With [x,2], I am trying to select the column of data.

 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.

See other posting; each file that I used is separated by an empty
line. This error seems to occur with the data set size as shown in the
files.

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


Re: [R] Merge failure using zoo package

2010-04-02 Thread Gabor Grothendieck
The code does not run with the files.  I need the requested
information, namely a single file containing code and data and that I
can just copy into a session without editing and see the result you
see.

On Fri, Apr 2, 2010 at 11:27 AM, e-letter inp...@gmail.com wrote:
 On 02/04/2010, Gabor Grothendieck ggrothendi...@gmail.com wrote:
 The files only have one data column.  What is the meaning of x[,2],
 etc. ?   What is z1?

 I only want to merge one column from one file with one column from
 another file. With [x,2], I am trying to select the column of data.

 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.

 See other posting; each file that I used is separated by an empty
 line. This error seems to occur with the data set size as shown in the
 files.


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


Re: [R] Merge failure using zoo package

2010-04-02 Thread e-letter
On 02/04/2010, Gabor Grothendieck ggrothendi...@gmail.com wrote:
 The code does not run with the files.  I need the requested
 information, namely a single file containing code and data and that I
 can just copy into a session without editing and see the result you
 see.

I don't understand how I can combine the four csv files into a single
file of data and terminal commands? Anyway, further terminal output.

The following also occurs with correction of the commands. The data
merge is incomplete (to 1:27:30); data set 1 ends at time 1:45:30;
data set 2 1:31:59

 library(chron)
 library(zoo)
 z1-read.zoo(test1.csv,header=TRUE,sep=,,FUN=times)
 z2-read.zoo(test2.csv,header=TRUE,sep=,,FUN=times)
 z3-(na.approx(merge(z1[,2],z2[,2]),time(z1)))
 z3
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
01:02:23 0.31401158 0.75867726
01:02:30 0.01495898 0.75079270
01:03:00 0.27035612 0.74290813
01:03:06 0.48274755 0.73502357
01:03:30 0.69513898 0.83760282
01:03:50 0.57982828 0.94018206
01:04:00 0.46451758 0.83306352
01:04:30 0.61672569 0.72594497
01:04:35 0.72084346 0.61882643
01:05:00 0.82496122 0.65150068
01:05:21 0.58631138 0.68417492
01:05:30 0.34766154 0.47526482
01:06:00 0.69618714 0.26635471
01:06:08 0.54326964 0.05744461
01:06:30 0.39035214 0.19544428
01:06:55 0.20357679 0.33344394
01:07:00 0.01680143 0.45147127
01:07:30 0.28576967 0.56949860
01:07:44 0.14891191 0.68752593
01:08:00 0.01205416 0.51591885
01:08:30 0.89637254 0.34431177
01:08:33 0.76392454 0.17270469
01:09:00 0.63147653 0.49396296
01:09:23 0.32334896 0.81522124
01:09:30 0.01522139 0.77116200
01:10:00 0.27661960 0.72710276
01:10:03 0.39318042 0.68304352
01:10:30 0.50974124 0.53539217
01:10:43 0.59558051 0.38774082
01:11:00 0.68141977 0.61475486
01:11:23 0.79433915 0.84176890
01:11:30 0.90725854 0.59232742
01:12:00 0.83823443 0.34288594
01:12:04 0.68591842 0.0936
01:12:30 0.53360241 0.11388206
01:12:44 0.35564718 0.13431965
01:13:00 0.17769196 0.52821343
01:13:25 0.50603906 0.92210721
01:13:30 0.83438616 0.72684026
01:14:00 0.67248807 0.53157330
01:14:06 0.38620370 0.33630635
01:14:30 0.09991933 0.45160464
01:14:47 0.06663450 0.56690294
01:15:00 0.03334966 0.33280555
01:15:29 0.48313660 0.09870816
01:15:30 0.93292355 0.32535246
01:16:00 0.15990837 0.55199675
01:16:11 0.10672443 0.77864105
01:16:30 0.05354050 0.69833773
01:16:53 0.30317627 0.61803441
01:17:00 0.55281203 0.44246870
01:17:30 0.37845690 0.26690299
01:17:35 0.63448528 0.09133728
01:18:00 0.89051365 0.09029608
01:18:17 0.52862829 0.08925487
01:18:30 0.16674292 0.49098302
01:19:00 0.85458626 0.89271117
01:19:30 0.19278550 0.72938430
01:19:42 0.46259477 0.56605742
01:20:00 0.73240405 0.77563138
01:20:25 0.44828965 0.98520534
01:20:30 0.16417524 0.87715304
01:21:00 0.73878212 0.76910073
01:21:08 0.62834165 0.66104843
01:21:30 0.51790118 0.81526716
01:21:51 0.67433278 0.96948589
01:22:00 0.83076438 0.66529956
01:22:30 0.4704 0.36111323
01:22:34 0.24832072 0.05692690
01:23:00 0.02108640 0.38790073
01:23:17 0.42509847 0.71887456
01:23:30 0.82911053 0.43395599
01:24:00 0.9646 0.14903741
01:24:30 0.14493657 0.50736593
01:24:43 0.49457995 0.86569445
01:25:00 0.84422332 0.57246479
01:25:26 0.63006153 0.27923513
01:25:30 0.41589974 0.51404020
01:26:00 0.67606367 0.74884526
01:26:09 0.34106401 0.98365033
01:26:30 0.00606434 0.53336716
01:26:53 0.30279212 0.08308399
01:27:00 0.59951991 0.34562608
01:27:30 0.43949260 0.60816818


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


Re: [R] Merge failure using zoo package

2010-04-02 Thread Gabor Grothendieck
Below is the format that was requested.  This has the data followed by
the corrected code at the end.  There are several things that were
wrong:

1. z1[,2] is wrong since z1 is a vector, not a 2d matrix.  Ditto for
z2.  Ideally zoo would have given an error message but in any case its
wrong.  It should be just z1.
2. The merge works ok but the second argument to na.approx should be
xout=time(z1).   xout= was missing.
3. there were a number of bugs removed from na.approx in the devel
version of zoo.  I don't think they impact this but if you have any
problems with na.approx then uncomment the source statement in the
code below. It will bring in the development version of na.approx into
your workspace.

Lines1 - time1,dataset1
01:01:00,0.73512097
01:01:30,0.34860813
01:02:00,0.61306418
01:02:30,0.01495898
01:03:00,0.27035612
01:03:30,0.69513898
01:04:00,0.46451758
01:04:30,0.61672569
01:05:00,0.82496122
01:05:30,0.34766154
01:06:00,0.69618714
01:06:30,0.39035214
01:07:00,0.01680143
01:07:30,0.28576967
01:08:00,0.01205416
01:08:30,0.89637254
01:09:00,0.63147653
01:09:30,0.01522139
01:10:00,0.27661960
01:10:30,0.50974124
01:11:00,0.68141977
01:11:30,0.90725854
01:12:00,0.83823443
01:12:30,0.53360241
01:13:00,0.17769196
01:13:30,0.83438616
01:14:00,0.67248807
01:14:30,0.09991933
01:15:00,0.03334966
01:15:30,0.93292355
01:16:00,0.15990837
01:16:30,0.05354050
01:17:00,0.55281203
01:17:30,0.37845690
01:18:00,0.89051365
01:18:30,0.16674292
01:19:00,0.85458626
01:19:30,0.19278550
01:20:00,0.73240405
01:20:30,0.16417524
01:21:00,0.73878212
01:21:30,0.51790118
01:22:00,0.83076438
01:22:30,0.4704
01:23:00,0.02108640
01:23:30,0.82911053
01:24:00,0.9646
01:24:30,0.14493657
01:25:00,0.84422332
01:25:30,0.41589974
01:26:00,0.67606367
01:26:30,0.00606434
01:27:00,0.59951991
01:27:30,0.43949260
01:28:00,0.66297385
01:28:30,0.33131298
01:29:00,0.06102041
01:29:30,0.84722118
01:30:00,0.46841491
01:30:30,0.34200755
01:31:00,0.87386578
01:31:30,0.70737403
01:32:00,0.23978781
01:32:30,0.11787278
01:33:00,0.14679814
01:33:30,0.65217063
01:34:00,0.81355908
01:34:30,0.31583482
01:35:00,0.92167666
01:35:30,0.55931271
01:36:00,0.13641271
01:36:30,0.35048575
01:37:00,0.17243584
01:37:30,0.93645686
01:38:00,0.85356548
01:38:30,0.61399352
01:39:00,0.05910707
01:39:30,0.01721605
01:40:00,0.94845557
01:40:30,0.48117810
01:41:00,0.34752402
01:41:30,0.59295472
01:42:00,0.64267429
01:42:30,0.57859933
01:43:00,0.00201441
01:43:30,0.32530995
01:44:00,0.25474645
01:44:30,0.93187534
01:45:00,0.99361033
01:45:30,0.16591641

Lines2 - time2,dataset2
01:01:01,0.17558467
01:01:42,0.23806514
01:02:23,0.75867726
01:03:06,0.73502357
01:03:50,0.94018206
01:04:35,0.61882643
01:05:21,0.68417492
01:06:08,0.05744461
01:06:55,0.33344394
01:07:44,0.68752593
01:08:33,0.17270469
01:09:23,0.81522124
01:10:03,0.68304352
01:10:43,0.38774082
01:11:23,0.84176890
01:12:04,0.0936
01:12:44,0.13431965
01:13:25,0.92210721
01:14:06,0.33630635
01:14:47,0.56690294
01:15:29,0.09870816
01:16:11,0.77864105
01:16:53,0.61803441
01:17:35,0.09133728
01:18:17,0.08925487
01:19:00,0.89271117
01:19:42,0.56605742
01:20:25,0.98520534
01:21:08,0.66104843
01:21:51,0.96948589
01:22:34,0.05692690
01:23:17,0.71887456
01:24:00,0.14903741
01:24:43,0.86569445
01:25:26,0.27923513
01:26:09,0.98365033
01:26:53,0.08308399
01:27:36,0.87071027
01:28:19,0.26475705
01:29:03,0.76409811
01:29:47,0.59563256
01:30:31,0.23995054
01:31:14,0.00951054
01:31:59,0.21367270

Lines3 - time1,dataset1
01:02:30,0.01495898
01:03:00,0.27035612
01:03:30,0.69513898
01:04:00,0.46451758
01:04:30,0.61672569
01:05:00,0.82496122
01:05:30,0.34766154
01:06:00,0.69618714
01:06:30,0.39035214
01:07:00,0.01680143
01:07:30,0.28576967
01:08:00,0.01205416
01:08:30,0.89637254
01:09:00,0.63147653
01:09:30,0.01522139
01:10:00,0.27661960
01:10:30,0.50974124
01:11:00,0.68141977
01:11:30,0.90725854
01:12:00,0.83823443
01:12:30,0.53360241
01:13:00,0.17769196
01:13:30,0.83438616
01:14:00,0.67248807
01:14:30,0.09991933
01:15:00,0.03334966
01:15:30,0.93292355
01:16:00,0.15990837
01:16:30,0.05354050
01:17:00,0.55281203
01:17:30,0.37845690
01:18:00,0.89051365
01:18:30,0.16674292
01:19:00,0.85458626
01:19:30,0.19278550
01:20:00,0.73240405
01:20:30,0.16417524
01:21:00,0.73878212
01:21:30,0.51790118
01:22:00,0.83076438
01:22:30,0.4704
01:23:00,0.02108640
01:23:30,0.82911053
01:24:00,0.9646
01:24:30,0.14493657
01:25:00,0.84422332
01:25:30,0.41589974
01:26:00,0.67606367
01:26:30,0.00606434
01:27:00,0.59951991
01:27:30,0.43949260
01:28:00,0.66297385
01:28:30,0.33131298
01:29:00,0.06102041
01:29:30,0.84722118
01:30:00,0.46841491
01:30:30,0.34200755
01:31:00,0.87386578
01:31:30,0.70737403
01:32:00,0.23978781
01:32:30,0.11787278
01:33:00,0.14679814
01:33:30,0.65217063
01:34:00,0.81355908
01:34:30,0.31583482
01:35:00,0.92167666
01:35:30,0.55931271
01:36:00,0.13641271
01:36:30,0.35048575
01:37:00,0.17243584
01:37:30,0.93645686
01:38:00,0.85356548
01:38:30,0.61399352
01:39:00,0.05910707
01:39:30,0.01721605
01:40:00,0.94845557

Re: [R] Merge failure using zoo package

2010-04-02 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of e-letter
 Sent: Friday, April 02, 2010 9:20 AM
 To: Gabor Grothendieck
 Cc: r-help@r-project.org
 Subject: Re: [R] Merge failure using zoo package
 
 On 02/04/2010, Gabor Grothendieck ggrothendi...@gmail.com wrote:
  The code does not run with the files.  I need the requested
  information, namely a single file containing code and data 
 and that I
  can just copy into a session without editing and see the result you
  see.
 
 I don't understand how I can combine the four csv files into a single
 file of data and terminal commands?

One way is to use a call to textConnection() instead of a
file name.

E.g., if you show a file called data.txt containing the lines
VarA VarB
   12
   34
and you read that into R with
   data-read.table(header=TRUE, data.txt)
then the R-helper needs to copy the file contents into
an editor, save the file under the appropriate name,
then copy the command into an R session.

However, you can replace the file and the original read.table
command with one command that an R-helper can paste into an
R seesion:

   data - read.table(header=TRUE, textConnection(
VarA VarB
   12
   34
))

Another approach is to use dput(data) to print the
dataset and stick a 'data-' on the front of what
was printed.  E.g.,  with the above 'data' you can do
   dput(data)
  structure(list(VarA = c(1L, 3L), VarB = c(2L, 4L)), .Names = c(VarA,

  VarB), class = data.frame, row.names = c(NA, -2L))
and send R-help the command
  data - 
  structure(list(VarA = c(1L, 3L), VarB = c(2L, 4L)), .Names = c(VarA,

  VarB), class = data.frame, row.names = c(NA, -2L))
You may have to insert some line breaks in sensible positions
so that Outlook or Exchange doesn't break lines in nonsensical
positions.  Again, the R-helper can copy and paste that
code into an R session and come up with a dataset identical
to yours.

(I've seen copy-n-pastable code in R-help that starts with
   remove(list=ls())
The suggestion to remove all objects really puts off R-helpers.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 Anyway, further terminal output.
 
 The following also occurs with correction of the commands. The data
 merge is incomplete (to 1:27:30); data set 1 ends at time 1:45:30;
 data set 2 1:31:59
 
  library(chron)
  library(zoo)
  z1-read.zoo(test1.csv,header=TRUE,sep=,,FUN=times)
  z2-read.zoo(test2.csv,header=TRUE,sep=,,FUN=times)
  z3-(na.approx(merge(z1[,2],z2[,2]),time(z1)))
  z3
 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
 01:02:23 0.31401158 0.75867726
 01:02:30 0.01495898 0.75079270
 01:03:00 0.27035612 0.74290813
 01:03:06 0.48274755 0.73502357
 01:03:30 0.69513898 0.83760282
 01:03:50 0.57982828 0.94018206
 01:04:00 0.46451758 0.83306352
 01:04:30 0.61672569 0.72594497
 01:04:35 0.72084346 0.61882643
 01:05:00 0.82496122 0.65150068
 01:05:21 0.58631138 0.68417492
 01:05:30 0.34766154 0.47526482
 01:06:00 0.69618714 0.26635471
 01:06:08 0.54326964 0.05744461
 01:06:30 0.39035214 0.19544428
 01:06:55 0.20357679 0.33344394
 01:07:00 0.01680143 0.45147127
 01:07:30 0.28576967 0.56949860
 01:07:44 0.14891191 0.68752593
 01:08:00 0.01205416 0.51591885
 01:08:30 0.89637254 0.34431177
 01:08:33 0.76392454 0.17270469
 01:09:00 0.63147653 0.49396296
 01:09:23 0.32334896 0.81522124
 01:09:30 0.01522139 0.77116200
 01:10:00 0.27661960 0.72710276
 01:10:03 0.39318042 0.68304352
 01:10:30 0.50974124 0.53539217
 01:10:43 0.59558051 0.38774082
 01:11:00 0.68141977 0.61475486
 01:11:23 0.79433915 0.84176890
 01:11:30 0.90725854 0.59232742
 01:12:00 0.83823443 0.34288594
 01:12:04 0.68591842 0.0936
 01:12:30 0.53360241 0.11388206
 01:12:44 0.35564718 0.13431965
 01:13:00 0.17769196 0.52821343
 01:13:25 0.50603906 0.92210721
 01:13:30 0.83438616 0.72684026
 01:14:00 0.67248807 0.53157330
 01:14:06 0.38620370 0.33630635
 01:14:30 0.09991933 0.45160464
 01:14:47 0.06663450 0.56690294
 01:15:00 0.03334966 0.33280555
 01:15:29 0.48313660 0.09870816
 01:15:30 0.93292355 0.32535246
 01:16:00 0.15990837 0.55199675
 01:16:11 0.10672443 0.77864105
 01:16:30 0.05354050 0.69833773
 01:16:53 0.30317627 0.61803441
 01:17:00 0.55281203 0.44246870
 01:17:30 0.37845690 0.26690299
 01:17:35 0.63448528 0.09133728
 01:18:00 0.89051365 0.09029608
 01:18:17 0.52862829 0.08925487
 01:18:30 0.16674292 0.49098302
 01:19:00 0.85458626 0.89271117
 01:19:30 0.19278550 0.72938430
 01:19:42 0.46259477 0.56605742
 01:20:00 0.73240405 0.77563138
 01:20:25 0.44828965 0.98520534
 01:20:30 0.16417524 0.87715304
 01:21:00 0.73878212 0.76910073
 01:21:08 0.62834165 0.66104843
 01:21:30 0.51790118 0.81526716
 01:21:51 0.67433278 0.96948589
 01:22:00 0.83076438 0.66529956
 01:22:30 0.4704 0.36111323
 01:22:34 0.24832072 0.05692690
 01:23:00 0.02108640 0.38790073
 01:23:17 0.42509847 0.71887456
 01:23:30

Re: [R] Merge failure using zoo package

2010-04-02 Thread Gabor Grothendieck
On Fri, Apr 2, 2010 at 1:01 PM, William Dunlap wdun...@tibco.com wrote:
 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of e-letter
 Sent: Friday, April 02, 2010 9:20 AM
 To: Gabor Grothendieck
 Cc: r-help@r-project.org
 Subject: Re: [R] Merge failure using zoo package

 On 02/04/2010, Gabor Grothendieck ggrothendi...@gmail.com wrote:
  The code does not run with the files.  I need the requested
  information, namely a single file containing code and data
 and that I
  can just copy into a session without editing and see the result you
  see.

 I don't understand how I can combine the four csv files into a single
 file of data and terminal commands?

 One way is to use a call to textConnection() instead of a
 file name.

 E.g., if you show a file called data.txt containing the lines
 VarA VarB
   1    2
   3    4
 and you read that into R with
   data-read.table(header=TRUE, data.txt)
 then the R-helper needs to copy the file contents into
 an editor, save the file under the appropriate name,
 then copy the command into an R session.

 However, you can replace the file and the original read.table
 command with one command that an R-helper can paste into an
 R seesion:

   data - read.table(header=TRUE, textConnection(
 VarA VarB
   1    2
   3    4
 ))

I personally rarely use this form since it makes it harder to
transition to the case where you have a file name.  I generally prefer
the textConnection form.


 Another approach is to use dput(data) to print the
 dataset and stick a 'data-' on the front of what
 was printed.  E.g.,  with the above 'data' you can do
   dput(data)
  structure(list(VarA = c(1L, 3L), VarB = c(2L, 4L)), .Names = c(VarA,

  VarB), class = data.frame, row.names = c(NA, -2L))
 and send R-help the command
  data -
  structure(list(VarA = c(1L, 3L), VarB = c(2L, 4L)), .Names = c(VarA,

  VarB), class = data.frame, row.names = c(NA, -2L))

This form is convenient but in some cases it may leave one wondering
how the data came about.  As long as that is not in question then dput
is really nice.

 You may have to insert some line breaks in sensible positions
 so that Outlook or Exchange doesn't break lines in nonsensical
 positions.  Again, the R-helper can copy and paste that
 code into an R session and come up with a dataset identical
 to yours.

 (I've seen copy-n-pastable code in R-help that starts with
   remove(list=ls())
 The suggestion to remove all objects really puts off R-helpers.)

Yes, that is unacceptable code to post.  It can really cause horrible
problems for readers.  I personally never use code like this.


 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 Anyway, further terminal output.

 The following also occurs with correction of the commands. The data
 merge is incomplete (to 1:27:30); data set 1 ends at time 1:45:30;
 data set 2 1:31:59

  library(chron)
  library(zoo)
  z1-read.zoo(test1.csv,header=TRUE,sep=,,FUN=times)
  z2-read.zoo(test2.csv,header=TRUE,sep=,,FUN=times)
  z3-(na.approx(merge(z1[,2],z2[,2]),time(z1)))
  z3
             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
 01:02:23 0.31401158 0.75867726
 01:02:30 0.01495898 0.75079270
 01:03:00 0.27035612 0.74290813
 01:03:06 0.48274755 0.73502357
 01:03:30 0.69513898 0.83760282
 01:03:50 0.57982828 0.94018206
 01:04:00 0.46451758 0.83306352
 01:04:30 0.61672569 0.72594497
 01:04:35 0.72084346 0.61882643
 01:05:00 0.82496122 0.65150068
 01:05:21 0.58631138 0.68417492
 01:05:30 0.34766154 0.47526482
 01:06:00 0.69618714 0.26635471
 01:06:08 0.54326964 0.05744461
 01:06:30 0.39035214 0.19544428
 01:06:55 0.20357679 0.33344394
 01:07:00 0.01680143 0.45147127
 01:07:30 0.28576967 0.56949860
 01:07:44 0.14891191 0.68752593
 01:08:00 0.01205416 0.51591885
 01:08:30 0.89637254 0.34431177
 01:08:33 0.76392454 0.17270469
 01:09:00 0.63147653 0.49396296
 01:09:23 0.32334896 0.81522124
 01:09:30 0.01522139 0.77116200
 01:10:00 0.27661960 0.72710276
 01:10:03 0.39318042 0.68304352
 01:10:30 0.50974124 0.53539217
 01:10:43 0.59558051 0.38774082
 01:11:00 0.68141977 0.61475486
 01:11:23 0.79433915 0.84176890
 01:11:30 0.90725854 0.59232742
 01:12:00 0.83823443 0.34288594
 01:12:04 0.68591842 0.0936
 01:12:30 0.53360241 0.11388206
 01:12:44 0.35564718 0.13431965
 01:13:00 0.17769196 0.52821343
 01:13:25 0.50603906 0.92210721
 01:13:30 0.83438616 0.72684026
 01:14:00 0.67248807 0.53157330
 01:14:06 0.38620370 0.33630635
 01:14:30 0.09991933 0.45160464
 01:14:47 0.06663450 0.56690294
 01:15:00 0.03334966 0.33280555
 01:15:29 0.48313660 0.09870816
 01:15:30 0.93292355 0.32535246
 01:16:00 0.15990837 0.55199675
 01:16:11 0.10672443 0.77864105
 01:16:30 0.05354050 0.69833773
 01:16:53 0.30317627 0.61803441
 01:17:00 0.55281203 0.44246870
 01:17:30 0.37845690 0.26690299
 01:17:35 0.63448528 0.09133728
 01:18:00 0.89051365 0.09029608
 01:18:17