search for: ncol2

Displaying 1 result from an estimated 1 matches for "ncol2".

Did you mean: col2
2003 Oct 31
2
Summing elements in a list
...weighted sum of the corresponding matrices. I could use a loop but this is a nested calculation so I was hoping there is a more efficient way to do this. To help clarify, here is the code I would use with a for loop result <- list(mat1=matrix(0,nrow1,ncol1), mat2=matrix(0,nrow2,ncol2)) for (i in seq(along=matlist)) { result$mat1 <- result$mat1+w[i]*matlist[[i]]$mat1 result$mat2 <- result$mat2+w[i]*matlist[[i]]$mat2 } I apologise if this is a trivial question. Unfortunately I don't have my copy of V&R S Programming to hand. Thanks for your help, Angelo --...