[R] multiple time series
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Sep 27 08:30:14 CEST 2004
On Mon, 27 Sep 2004, Banachewicz KP wrote:
> thanks Dirk, I missed the obvious z[,i] option (shame on me ;-(
> however, when I tried to use z$foo I get a NULL, despite the fact that
> this particular column is not empty. any idea why ?
A multiple time series (as created by ts()) is a *matrix* not a data
frame. [You can create ts data frames via ts.union.]
So index its columns as a matrix, only.
>
> rg,
>
> Konrad
>
> On Sun, 26 Sep 2004, Dirk Eddelbuettel wrote:
> > 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.
> >
> > Dirk
> >
> > --
> > Those are my principles, and if you don't like them... well, I have others.
> > -- Groucho Marx
> >
>
> ______________________________________________
> 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
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list