[R] Loop

livia yn19832 at msn.com
Mon Oct 29 16:40:06 CET 2007


Hello, I would like to build a list through the following codes."know1" &
"know2" are some list obtained before. "know1" has the length of 50 (as for
i), "know2" has the lengh of 50 (as for i), know1[[i]] has the length of
1000, know2[[i]] has the length of 1132. I would like to get the list
"finalreturnc", for which 
finalreturnc[[i]][[j]] =know1[[i]]*know2[[i]][j]. But the loop does not seem
to work, eg, I got the follwing value of finalreturnc
.......
[[50]][[1131]]
NULL

[[50]][[1132]]
1] -3.467047e-03 -2.963263e-02...

finalreturnc <- list()
volc1 <- list()
for (i in 1:50){
   for (j in 1:1132) {      
    volc1[[j]] <- vector()
    volc1[[j]] <- know1[[i]]*know2[[i]][j]
    finalreturnc[[i]]<- list()
    finalreturnc[[i]][[j]]<- volc1[[j]]
   }
 }

Could anyone give me some advice? Many thanks
-- 
View this message in context: http://www.nabble.com/Loop-tf4712520.html#a13470236
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list