[R] Inputing data from multiple files as time series objects

ManuelPerera-Chang@fmc-ag.com ManuelPerera-Chang at fmc-ag.com
Fri Nov 11 16:24:48 CET 2005





Hi Constantine,

I have not tested it but try ...

y<-c("IBM","MS","DELL","SIEMENS","SUN")

read.data.myfunction<-function(x){
                  for(i in 1:length(x))
                  {
                  paste(x[i],sep="") <-
ts(read.table(paste(x[i],".txt",sep=""), header = TRUE))
                  }
                  }

read.data.myfunction(y)


Manuel



                                                                                                                                           
                      Constantine                                                                                                          
                      Tsardounis                   To:       r-help at stat.math.ethz.ch                                                      
                      <costas.magnuse at gmail        cc:                                                                                     
                      .com>                        Subject:  [R] Inputing data from multiple files as time series objects                  
                      Sent by:                                                                                                             
                      r-help-bounces at stat.m                                                                                                
                      ath.ethz.ch                                                                                                          
                                                                                                                                           
                                                                                                                                           
                      11.11.2005 15:07                                                                                                     
                                                                                                                                           
                                                                                                                                           




Hello to everyone,...

I am a new R ambitious user. I would like to be the first at my
department using R, but I have encountered a difficulty during the
last days that I cannot overcome reading help() and searching over the
net.
Problem:
I have multiple files with financial data like the following (header
included):
E.g.:
filename: AOL.txt
aol.txt
4
3
5
3...

filename: IBM.txt
ibm.txt
6
2
5
2...

I would like to input these data in R as time-series objects with
their corresponding names automatically, so that I can manipulate them
(exempli gratia plot acf, pacf, differntiate them, make adf tests,
etc)
For example: I could do that by hand using:
AOL <- ts(read.table(AOL.txt, header = TRUE))))
IBM <- ts(read.table(IBM.txt, header = TRUE))))
but is there another way to achieve the same actions as above with a
more versatile way? (for example loops?)
Or would you suggest inputing these data with another way or as other
objects?

Thank you very much in advance,...

Tsardounis Costas

______________________________________________
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