[R] TS data frames

Welch, Ivo ivo.welch at yale.edu
Sun May 18 20:21:08 CEST 2003

hi chaps:  apologies, more naive beginner's questions.  my data sets 
contain multiple time series and look like

date   x   y
196211   12   1
196212   4   2
196301   44   5

so dataset <- read.table("data.dat", header=T); works well enough.  
tsdataset<- ts(dataset, freq=12, start=c(1962,11))  also seems to work.  
summary(tsdataset) and print(tsdataset) show that this operation did 
what I intended. 

* Alas, tsdataset$x no longer works.  how do I specify data series 
inside tsdataset now?

* Is there a time-series equivalent of read.table(), preferably allowing 
me to specify that the data column is the appropriate data in yyyymm format?

* For arguments sake, let's assume I want to do something with every 
variable in my data set.  for example, I want to convert every single 
data series into a time series.  "for (a in names(dataset)) a<-ts(a)" of 
course does not do what I want, because the destination is a vector 
named a, not a vector named by the contents of a.  I need sort of an 
eval.  similarly "for (a in names(dataset)) a<- uppercase-name(a)".   
Generically, how do I do something with every single series in a data 
set, and then assign it back to replace the old series within the data set?

* unrelated:  are there a push, pop, shift functions for vectors, ala perl?

* unrelated:  summary(vector) gives information in a row.  
summary(dataset) gives information in blocks.  can it be instructed to 
give information in rows, too?  where would I find documentation on 
issues like this?

sorry for all these questions.  help appreciated.


an R novice

More information about the R-help mailing list