[R] how to handle irregularly spaced data as timeseries

2008-12-02 Thread Kirk Wythers
I have a set of modeled climate data recorded at irregular intervals.  
The format of the data is such that there are monthly measurements for  
the years 2000, 2020, 2050, 2080, etc. Therefore I have 12 regular  
records, a skip of some number of years, then 12 more monthly records,  
another skip, and so on I created a dataframe from .txt with the  
read.table() command. For starters I need to simply plot the data as a  
timeseries with DATE on the x axis. I am just getting my feet wet with  
R, so I'm struggling a bit to follow the help() pages. Can anyone  
point me in the proper direction? Thank you in advance.


Here is a piece of the dataframe:

 cloq.worldclim.HADCM3.A2a
  DATE YEAR MONTH DAY DOY TMAX  TMINPAR PRECIP
1  15-Jan-2000 2000 1  15  16 -7.2 -19.7 334.992.5
2  15-Feb-2000 2000 2  15  46 -3.5 -16.8 471.481.7
3  15-Mar-2000 2000 3  15  75  2.7  -9.4 636.964.1
4  15-Apr-2000 2000 4  15 106 11.3  -2.1 726.605.6
5  15-May-2000 2000 5  15 136 18.9   3.3 767.508.3
6  15-Jun-2000 2000 6  15 167 23.8   8.3 783.51   10.3
7  15-Jul-2000 2000 7  15 197 26.9  12.1 827.879.9
8  15-Aug-2000 2000 8  15 228 25.3  11.2 775.03   10.1
9  15-Sep-2000 2000 9  15 259 19.7   6.7 649.839.2
10 15-Oct-2000 200010  15 289 13.3   1.1 500.146.2
11 15-Nov-2000 200011  15 320  3.1  -6.3 349.144.4
12 15-Dec-2000 200012  15 350 -4.8 -15.4 293.072.9
13 15-Jan-2020 2020 1  15  16 -7.4 -19.6 334.992.5
14 15-Feb-2020 2020 2  15  46 -3.1 -16.2 471.481.7
15 15-Mar-2020 2020 3  15  75  3.0  -8.7 636.964.9
16 15-Apr-2020 2020 4  15 106 12.9  -5.0 726.607.4
17 15-May-2020 2020 5  15 136 20.1   4.4 767.508.8
18 15-Jun-2020 2020 6  15 167 25.2   9.6 783.51   10.4
19 15-Jul-2020 2020 7  15 197 28.9  13.6 827.879.4
20 15-Aug-2020 2020 8  15 228 27.3  13.1 775.03   11.6
21 15-Sep-2020 2020 9  15 259 22.0   8.8 649.839.6
22 15-Oct-2020 202010  15 289 15.4   2.6 500.146.8
23 15-Nov-2020 202011  15 320  4.3  -4.8 349.144.8
24 15-Dec-2020 202012  15 350 -4.1 -14.3 293.072.5
25 15-Jan-2050 2050 1  15  16 -5.5 -17.3 334.993.2
26 15-Feb-2050 2050 2  15  46 -1.7 -14.2 471.481.8
27 15-Mar-2050 2050 3  15  75  4.0  -7.1 636.965.1
28 15-Apr-2050 2050 4  15 106 13.4  -3.0 726.607.1
29 15-May-1950 2050 5  15 136 21.7   5.8 767.508.4
30 15-Jun-2050 2050 6  15 167 27.2  11.2 783.519.5
31 15-Jul-2050 2050 7  15 197 31.2  15.3 827.879.4
32 15-Aug-2050 2050 8  15 228 30.4  15.0 775.039.6
33 15-Sep-2050 2050 9  15 259 23.8  10.1 649.83   10.3
34 15-Oct-2050 205010  15 289 16.6   3.9 500.147.7
35 15-Nov-2050 205011  15 320  5.5  -3.6 349.145.3
36 15-Dec-2050 205012  15 350 -3.3 -13.2 293.072.5

__
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] how to handle irregularly spaced data as timeseries

2008-12-02 Thread Gabor Grothendieck
Have a look at the zoo package.  There are three vignettes (pdf documents)
included with the package that give many examples of its use.  Also
see ?read.zoo, ?plot.zoo and ?xyplot.zoo

You will need something like:

library(zoo)
z - read.zoo(myfile, ...whatever...)
plot(z)


On Tue, Dec 2, 2008 at 7:47 PM, Kirk Wythers [EMAIL PROTECTED] wrote:
 I have a set of modeled climate data recorded at irregular intervals. The
 format of the data is such that there are monthly measurements for the years
 2000, 2020, 2050, 2080, etc. Therefore I have 12 regular records, a skip of
 some number of years, then 12 more monthly records, another skip, and so
 on I created a dataframe from .txt with the read.table() command. For
 starters I need to simply plot the data as a timeseries with DATE on the x
 axis. I am just getting my feet wet with R, so I'm struggling a bit to
 follow the help() pages. Can anyone point me in the proper direction? Thank
 you in advance.

 Here is a piece of the dataframe:

 cloq.worldclim.HADCM3.A2a
  DATE YEAR MONTH DAY DOY TMAX  TMINPAR PRECIP
 1  15-Jan-2000 2000 1  15  16 -7.2 -19.7 334.992.5
 2  15-Feb-2000 2000 2  15  46 -3.5 -16.8 471.481.7
 3  15-Mar-2000 2000 3  15  75  2.7  -9.4 636.964.1
 4  15-Apr-2000 2000 4  15 106 11.3  -2.1 726.605.6
 5  15-May-2000 2000 5  15 136 18.9   3.3 767.508.3
 6  15-Jun-2000 2000 6  15 167 23.8   8.3 783.51   10.3
 7  15-Jul-2000 2000 7  15 197 26.9  12.1 827.879.9
 8  15-Aug-2000 2000 8  15 228 25.3  11.2 775.03   10.1
 9  15-Sep-2000 2000 9  15 259 19.7   6.7 649.839.2
 10 15-Oct-2000 200010  15 289 13.3   1.1 500.146.2
 11 15-Nov-2000 200011  15 320  3.1  -6.3 349.144.4
 12 15-Dec-2000 200012  15 350 -4.8 -15.4 293.072.9
 13 15-Jan-2020 2020 1  15  16 -7.4 -19.6 334.992.5
 14 15-Feb-2020 2020 2  15  46 -3.1 -16.2 471.481.7
 15 15-Mar-2020 2020 3  15  75  3.0  -8.7 636.964.9
 16 15-Apr-2020 2020 4  15 106 12.9  -5.0 726.607.4
 17 15-May-2020 2020 5  15 136 20.1   4.4 767.508.8
 18 15-Jun-2020 2020 6  15 167 25.2   9.6 783.51   10.4
 19 15-Jul-2020 2020 7  15 197 28.9  13.6 827.879.4
 20 15-Aug-2020 2020 8  15 228 27.3  13.1 775.03   11.6
 21 15-Sep-2020 2020 9  15 259 22.0   8.8 649.839.6
 22 15-Oct-2020 202010  15 289 15.4   2.6 500.146.8
 23 15-Nov-2020 202011  15 320  4.3  -4.8 349.144.8
 24 15-Dec-2020 202012  15 350 -4.1 -14.3 293.072.5
 25 15-Jan-2050 2050 1  15  16 -5.5 -17.3 334.993.2
 26 15-Feb-2050 2050 2  15  46 -1.7 -14.2 471.481.8
 27 15-Mar-2050 2050 3  15  75  4.0  -7.1 636.965.1
 28 15-Apr-2050 2050 4  15 106 13.4  -3.0 726.607.1
 29 15-May-1950 2050 5  15 136 21.7   5.8 767.508.4
 30 15-Jun-2050 2050 6  15 167 27.2  11.2 783.519.5
 31 15-Jul-2050 2050 7  15 197 31.2  15.3 827.879.4
 32 15-Aug-2050 2050 8  15 228 30.4  15.0 775.039.6
 33 15-Sep-2050 2050 9  15 259 23.8  10.1 649.83   10.3
 34 15-Oct-2050 205010  15 289 16.6   3.9 500.147.7
 35 15-Nov-2050 205011  15 320  5.5  -3.6 349.145.3
 36 15-Dec-2050 205012  15 350 -3.3 -13.2 293.072.5

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