[R] how to handle irregularly spaced data as timeseries
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Dec 3 02:00:23 CET 2008
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 <kwythers at umn.edu> 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 TMIN PAR PRECIP
> 1 15-Jan-2000 2000 1 15 16 -7.2 -19.7 334.99 2.5
> 2 15-Feb-2000 2000 2 15 46 -3.5 -16.8 471.48 1.7
> 3 15-Mar-2000 2000 3 15 75 2.7 -9.4 636.96 4.1
> 4 15-Apr-2000 2000 4 15 106 11.3 -2.1 726.60 5.6
> 5 15-May-2000 2000 5 15 136 18.9 3.3 767.50 8.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.87 9.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.83 9.2
> 10 15-Oct-2000 2000 10 15 289 13.3 1.1 500.14 6.2
> 11 15-Nov-2000 2000 11 15 320 3.1 -6.3 349.14 4.4
> 12 15-Dec-2000 2000 12 15 350 -4.8 -15.4 293.07 2.9
> 13 15-Jan-2020 2020 1 15 16 -7.4 -19.6 334.99 2.5
> 14 15-Feb-2020 2020 2 15 46 -3.1 -16.2 471.48 1.7
> 15 15-Mar-2020 2020 3 15 75 3.0 -8.7 636.96 4.9
> 16 15-Apr-2020 2020 4 15 106 12.9 -5.0 726.60 7.4
> 17 15-May-2020 2020 5 15 136 20.1 4.4 767.50 8.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.87 9.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.83 9.6
> 22 15-Oct-2020 2020 10 15 289 15.4 2.6 500.14 6.8
> 23 15-Nov-2020 2020 11 15 320 4.3 -4.8 349.14 4.8
> 24 15-Dec-2020 2020 12 15 350 -4.1 -14.3 293.07 2.5
> 25 15-Jan-2050 2050 1 15 16 -5.5 -17.3 334.99 3.2
> 26 15-Feb-2050 2050 2 15 46 -1.7 -14.2 471.48 1.8
> 27 15-Mar-2050 2050 3 15 75 4.0 -7.1 636.96 5.1
> 28 15-Apr-2050 2050 4 15 106 13.4 -3.0 726.60 7.1
> 29 15-May-1950 2050 5 15 136 21.7 5.8 767.50 8.4
> 30 15-Jun-2050 2050 6 15 167 27.2 11.2 783.51 9.5
> 31 15-Jul-2050 2050 7 15 197 31.2 15.3 827.87 9.4
> 32 15-Aug-2050 2050 8 15 228 30.4 15.0 775.03 9.6
> 33 15-Sep-2050 2050 9 15 259 23.8 10.1 649.83 10.3
> 34 15-Oct-2050 2050 10 15 289 16.6 3.9 500.14 7.7
> 35 15-Nov-2050 2050 11 15 320 5.5 -3.6 349.14 5.3
> 36 15-Dec-2050 2050 12 15 350 -3.3 -13.2 293.07 2.5
More information about the R-help
mailing list