

Hi,

I am having trouble with matrices. I have 2 matrices as given below, and I am interested in using these matrices inside "for" loops used to calculate correlations.  I am creating a list with the names of the matrices assuming this list  could be indexed inside the 'for' loop to retrieve the matrix values.  But, as expected the code throws out an error. Can someone suggest a  better way to call these matrices inside the loops?

ts.m.dmi <- matrix(c(1:20), 4, 5) 
ts.m.soi <- matrix(c(21:40), 4, 5) 
ts.m.pe <- matrix(c(21:40), 4, 5) 

factors <- c("ts.m.dmi", "ts.m.soi")
for (j in 0:1){
y <- factors[j+1]

for (i in 1:5){

cor.pe.y <- cor(ts.m.pe[,2], y[,i])
ct.tst <- cor.test(ts.m.pe[,2], y[,i])
}
}

Thanks for your time. 

-- 
Regards,
Maha
Graduate Student
	[[alternative HTML version deleted]]

