Re: [R] synchronisation of time series data using interpolation

2009-09-28 Thread e-letter
I saved the data sets as files and then tried to refer to those files.
Therefore the instruction:

 z1-read.zoo(textConnection(/path/to/test1.txt)

means that I wanted to replace the manual data entry for Lines1 with a
file containing the data. It seems that your instructions only work
when data is typed from the command terminal. I cannot use data stored
in separated files. Command terminal output below:

 lines1-read.table(/path/to/test1.txt)
 lines2-read.table(/path/to/test2.txt)
Warning message:
incomplete final line found by readTableHeader on '/path/to/test2.txt'
in: read.table(/path/to/test2.txt)

This is test1 file:

01:00:00,500
01:00:15,600
01:00:30,750
01:00:45,720
01:01:00,700
01:01:15,725
01:01:30,640
01:01:45,710

This is test2 file:

01:00:12,20
01:01:01,55
01:01:55,22

Then I added a carriage return in test2 file and saved it:

01:00:12,20
01:01:01,55
01:01:55,22


Then I repeated the command terminal entry for lines2:

 lines2-read.table(/path/to/test2.txt)
 library(zoo)
 library(chron)
 z1-read.zoo(textConnection(lines1),header=FALSE,sep=,,FUN=times)
Error in textConnection(lines1) : 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.


Re: [R] synchronisation of time series data using interpolation

2009-09-28 Thread Gabor Grothendieck
You should be using read.zoo, not read.table.  This

read.zoo(textConnection(Lines1), ...)

becomes

read.zoo(test1.txt, ...)

etc.  See ?read.zoo and read the three vignettes in the zoo package.

On Mon, Sep 28, 2009 at 8:13 AM, e-letter inp...@gmail.com wrote:
 I saved the data sets as files and then tried to refer to those files.
 Therefore the instruction:

 z1-read.zoo(textConnection(/path/to/test1.txt)





 means that I wanted to replace the manual data entry for Lines1 with a
 file containing the data. It seems that your instructions only work
 when data is typed from the command terminal. I cannot use data stored
 in separated files. Command terminal output below:

 lines1-read.table(/path/to/test1.txt)
 lines2-read.table(/path/to/test2.txt)
 Warning message:
 incomplete final line found by readTableHeader on '/path/to/test2.txt'
 in: read.table(/path/to/test2.txt)

 This is test1 file:

 01:00:00,500
 01:00:15,600
 01:00:30,750
 01:00:45,720
 01:01:00,700
 01:01:15,725
 01:01:30,640
 01:01:45,710

 This is test2 file:

 01:00:12,20
 01:01:01,55
 01:01:55,22

 Then I added a carriage return in test2 file and saved it:

 01:00:12,20
 01:01:01,55
 01:01:55,22


 Then I repeated the command terminal entry for lines2:

 lines2-read.table(/path/to/test2.txt)
 library(zoo)
 library(chron)
 z1-read.zoo(textConnection(lines1),header=FALSE,sep=,,FUN=times)
 Error in textConnection(lines1) : 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.


Re: [R] synchronisation of time series data using interpolation

2009-09-26 Thread e-letter
I created separate text files for the 2 data sets. I enter the
following comands:

library(zoo)
library(chron)
z1-read.zoo(textConnection(/path/to/test1.txt),header=FALSE,sep=,,FUN=times)
z2-read.zoo(textConnection(/path/to/test2.txt),header=FALSE,sep=,,FUN=times)
z3-window(na.approx(merge(z1,z2)),time(z1))
plot(z3$z1,z3$z2)
Error in plot.window(xlim, ylim, log, asp, ...) :
need finite 'xlim' values
In addition: Warning messages:
1: no non-missing arguments to min; returning Inf in: min(x)
2: no non-missing arguments to max; returning -Inf in: max(x)
3: no non-missing arguments to min; returning Inf in: min(x)
4: no non-missing arguments to max; returning -Inf in: max(x)

The resultant graph window was blank, so I entered the following command

plot(z3$z1,z3$z2,xlim=c(0,100),ylim=c(0,100))

The graph window showed y axis (labelled 'z3$z1') and x axis (labelled 'Index').

I do not understand the instruction ...to use window to pick off...

__
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] synchronisation of time series data using interpolation

2009-09-26 Thread Gabor Grothendieck
Your files do not have data appropriate to your commands. Since you
did not provide the data (see last line of every message to r-help)
there is not much more that can be said.

On Sat, Sep 26, 2009 at 4:24 AM, e-letter inp...@gmail.com wrote:
 I created separate text files for the 2 data sets. I enter the
 following comands:

 library(zoo)
 library(chron)
 z1-read.zoo(textConnection(/path/to/test1.txt),header=FALSE,sep=,,FUN=times)
 z2-read.zoo(textConnection(/path/to/test2.txt),header=FALSE,sep=,,FUN=times)
 z3-window(na.approx(merge(z1,z2)),time(z1))
 plot(z3$z1,z3$z2)
 Error in plot.window(xlim, ylim, log, asp, ...) :
        need finite 'xlim' values
 In addition: Warning messages:
 1: no non-missing arguments to min; returning Inf in: min(x)
 2: no non-missing arguments to max; returning -Inf in: max(x)
 3: no non-missing arguments to min; returning Inf in: min(x)
 4: no non-missing arguments to max; returning -Inf in: max(x)

 The resultant graph window was blank, so I entered the following command

 plot(z3$z1,z3$z2,xlim=c(0,100),ylim=c(0,100))

 The graph window showed y axis (labelled 'z3$z1') and x axis (labelled 
 'Index').

 I do not understand the instruction ...to use window to pick off...


__
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] synchronisation of time series data using interpolation

2009-09-26 Thread e-letter
Test1 file contained data set 1, test2 contained data set 2

__
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] synchronisation of time series data using interpolation

2009-09-26 Thread Gabor Grothendieck
On Sat, Sep 26, 2009 at 9:08 AM, e-letter inp...@gmail.com wrote:
 Test1 file contained data set 1, test2 contained data set 2




Its not clear to me what you are referring to. The data in your
initial post do not exhibit this problem and there is no data in any
of your subsequent posts in this thread.  Here is what happens when I
run it with your data -- no errors:

 Lines1 - time,datum
+ 01:00:00,500
+ 01:00:15,600
+ 01:00:30,750
+ 01:00:45,720
+ 01:01:00,700
+ 01:01:15,725
+ 01:01:30,640
+ 01:01:45,710

 Lines2 - time,datum
+ 01:00:12,20
+ 01:01:01,55
+ 01:01:55,22

 library(zoo)
 library(chron)

 z1 - read.zoo(textConnection(Lines1), header = TRUE, sep = ,, FUN = times)
 z2 - read.zoo(textConnection(Lines2), header = TRUE, sep = ,, FUN = times)

 z3 - window(na.approx(merge(z1, z2)), time(z1))
 plot(z3$z1, z3$z2)


__
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] synchronisation of time series data using interpolation

2009-09-25 Thread Gabor Grothendieck
Create the series as zoo series from the data, and then merge them and
fill in NAs with interpolated values using na.approx.  Finally use
window to pick off the times that were in z1 and plot.  See the three
vignettes that come with zoo and for time and dates see the article in
R News 4/1 and its references.

Lines1 - time,datum
01:00:00,500
01:00:15,600
01:00:30,750
01:00:45,720
01:01:00,700
01:01:15,725
01:01:30,640
01:01:45,710

Lines2 - time,datum
01:00:12,20
01:01:01,55
01:01:55,22

library(zoo)
library(chron)

z1 - read.zoo(textConnection(Lines1), header = TRUE, sep = ,, FUN = times)
z2 - read.zoo(textConnection(Lines2), header = TRUE, sep = ,, FUN = times)

z3 - window(na.approx(merge(z1, z2)), time(z1))
plot(z3$z1, z3$z2)


On Fri, Sep 25, 2009 at 1:41 AM, e-letter inp...@gmail.com wrote:
 Readers,

 I have data with different time stamps that I wish to plot (for example):

 data set 1
 time(hh:mm:ss),datum
 01:00:00,500
 01:00:15,600
 01:00:30,750
 01:00:45,720
 01:01:00,700
 01:01:15,725
 01:01:30,640
 01:01:45,710
 data set 2
 time,datum
 01:00:12,20
 01:01:01,55
 01:01:55,22

 The time interval in data set 1 does not change, but the time interval
 in data set 2 does change, such that for a specific total time range
 (e.g. 60 minutes) there will be more data in data set 1 than in data
 set 2.

 I thought I could solve this problem using interpolation, to create a
 new data set using data from data set 2, interpolated to the time
 stamps in data set 1:

 data set 3
 time,datum
 01:00:00,18
 01:00:15,23
 01:00:30,30
 01:00:45,41
 01:01:00,53
 01:01:15,46
 01:01:30,38
 01:01:45,29

 Therefore I would then be able to plot the data in data set 1 against
 the interpolated data in data set 3, because there would be equal
 quantities of data in both data sets. I've looked at the interp
 function in the help manual, but I don't understand if this function
 can perform the task I want. Any advice please?

 Yours,

 rhelp at conference.jabber.org
 r 251 (27-06-07)
 mandriva 2008

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