[R] transformation matrice of vector into array

Jessica Gervais jessica.gervais at tudor.lu
Thu Jul 27 16:00:42 CEST 2006


Hi,

I need some help

I have a matrix M(m,n) in which each element is a vector V of lenght 6
 1      2      3      4      5      6      7
1   List,6 List,6 List,6 List,6 List,6 List,6 List,6
2   List,6 List,6 List,6 List,6 List,6 List,6 List,6
3   List,6 List,6 List,6 List,6 List,6 List,6 List,6
4   List,6 List,6 List,6 List,6 List,6 List,6 List,6


i would like to make the sum on the matrix of each element of the
matrix, that is to say 
sum(on the matrix)(M[j,][[j]][[1]])
sum(on the matrix)(M[j,][[j]][[2]])
...
sum(on the matrix)(M[j,][[j]][[6]])  

I don't really know how to do.
I thought it was possible to transform the matrix M into an array A of
dimension (m,n,6), and then use the command sum(colsums(A[,,1]), which
seems to be possible and quite fast.
...but I don't know how to convert a matrix of vector into an array....

As anyone any little idea about that ?

Thanks by advance

Jessica



More information about the R-help mailing list