[R] Cross correlations on many imported files.
Pur_045
jewellsean at gmail.com
Tue Jun 9 22:06:52 CEST 2009
Hello everyone,
I am trying to import all of the csv files from a particular folder and then
run cross correlations on each of them. i.e In the end have a matrix like
structure with cross correlations.
So far I have been able to import all of the data and run the ccf's but I
need a way to store the data in an array. I know that this could be done in
matlab by using something like both a for and nested for loop with the
results being place in results[i,j].
Below I only have tried to create an array and not the entire matrix
structure.
files <- list.files(pattern=".csv$")
for(i in seq(along=files)) { # start for loop with numeric or character
vector; numeric vector is often more flexible
x <- read.csv(files[i], skip=4,header=TRUE)
assign(paste('in',i,sep=""),x) # generates data frame object and names it
after content in variable 'i'
print(paste(files[i],paste('in',i,sep="")), quote=F)
}
library(tseries)
x<-get(paste('in',1,sep=""))
for(i in 1:length(files)-1){
y<-get(paste('in',i+1,sep=""))
xy<-ccf(x[[5]],y[[5]],lag.max=NULL,na.action=na.exclude)
*** result[i] = xy
}
Any help or advice would be greatly apperciated. Thanks in advance,
Sean
--
View this message in context: http://www.nabble.com/Cross-correlations-on-many-imported-files.-tp23950345p23950345.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list