[R] An entire data frame which is a time-series?
ajayshah at mayin.org
Tue Aug 17 09:41:52 CEST 2004
I have :
raw <- read.table("monthly.text", skip=3, sep="|",
"wpi", "g.wpi", "wpi.primary", "g.wpi.primary",
"wpi.fuel", "g.wpi.fuel", "wpi.manuf", "g.wpi.manuf",
"cpi.iw", "g.cpi.iw", "cpi.unme", "g.cpi.unme",
"cpi.al", "g.cpi.al", "cpi.rl", "g.cpi.rl"))
Now I can do things like:
g.wpi = ts(raw$g.wpi, frequency=12, start=c(1994,7))
and it works fine. One by one, I can make time-series objects.
Is there a way to tell R that the entire data frame is a set of
time-series, so that I don't have to go column by column and make a
new ts() out of each?
M = ts(raw, frequency=12, start=c(1994,7))
but this gives nonsense results. Also, syntax like M$wpi is a lot
nicer than M[,"wpi"]. Any ideas about what might work?
An unrelated suggestion: I found the documentation of ts() to be quite
daunting. I have been around time-series and computer programming for
decades. But it took me a while to handle the basics : to read in a
file, to make time-series vectors, to run ARMA models. This stuff
ought to be easier to learn. I tried to write an ARMA example, and put
it up on the web, which would've been a godsend to me if I had found
it earlier (http://www.mayin.org/~ajayshah/KB/R/tsa.html).
I believe that the R documentation framework could do well by always
having a 2000 word conceptual introduction + little tutorial on each
package, instead of straight jumping into man pages on each function
(which is the only documentation that we have presently).
Ajay Shah Consultant
ajayshah at mayin.org Department of Economic Affairs
http://www.mayin.org/ajayshah Ministry of Finance, New Delhi
More information about the R-help