[R] transformation matrice of vector into array

From: Jessica Gervais <jessica.gervais_at_tudor.lu>
Date: Fri 28 Jul 2006 - 00:00:42 EST


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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Jul 28 00:04:58 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 28 Jul 2006 - 02:16:47 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.