[R] multiple time series

Dirk Eddelbuettel edd at debian.org
Mon Sep 27 04:29:25 CEST 2004

On Mon, Sep 27, 2004 at 04:13:14AM +0200, Banachewicz KP wrote:
> Hello everybody,
> I have the following problem: I read a multiple time series (along with
> column names), and then need to manipulate the univariate components
> separately in order to compute the statistics of interest. Can someone
> tell me how can I access the univariates separately through their names ?

It works the usual way:

> z <- ts(matrix(rnorm(300), 100, 3), start=c(1961, 1), frequency=12)
> colnames(z) <- c("foo","bar","boo")
> summary(z[,"boo"])
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max.
-1.92700 -0.79140 -0.08982 -0.10660  0.54350  2.32600

You could also use z$foo, or z[,1] -- i.e. it works just like the data frames.


Those are my principles, and if you don't like them... well, I have others.
                                                -- Groucho Marx

More information about the R-help mailing list