[R] plot acf of several timeseries
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Apr 28 15:48:00 CEST 2006
Try this:
lapply(names(tslist), function(nm) acf(tslist[[nm]], main = nm))
On 4/28/06, Ulf Mehlig <ulf.mehlig at gmx.net> wrote:
> Hello r-help,
>
> I have a couple of time-series of different length and I would like to
> produce a simple overview plot showing the autocorrelation functions of
> the series. The time-series are stored in a dataframe like this:
>
> > test.data
> item year value
> 1 xxx 1961 -1.09
> 2 xxx 1962 0.21
> 3 xxx 1963 -0.81
> [trimmed]
> 8 yyy 1959 1.12
> 9 yyy 1960 1.44
> 10 yyy 1961 -1.97
> [trimmed]
>
> I transformed them to a list of ts-objects and did the plotting via
> lapply():
>
> > tslist <- by(test.data, test.data$item,
> function(x) ts(x$value, start=min(x$year), end=max(x$year)) )
> > par(mfcol=c(length(tslist), 1))
> > lapply(tslist, acf)
>
> Is there a possibility to adapt the procedure so that the name of
> "item" ('xxx', 'yyy', ...) is printed as title of each acf plot? I am
> sure that there are better ways to produce this type of plot ... do you
> have suggestions?
>
> Many thanks, Ulf
>
> --
> Ulf Mehlig <ulf.mehlig at gmx.net>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list