-------- Original Message -------- Subject: code to convert matrix to array solved Date: Thu, 22 Mar 2012 12:55:46 -0400 From: [email protected] To: [email protected] Hi folks I slightly modified an existing internal function of "shapes" package It works. #k=n°landmarks °m=n°dimensions read.inn<-function (matrix, k, m) { vectorr<-as.vector(t(matrix)) tem <- vectorr n <- length(tem)/(k * m) tem <- array(tem, c(m, k, n)) tem <- aperm(tem, c(2, 1, 3)) x <- tem x } Best Paolo Hi all, I write to ask if someone can sugest me some lines of code to convert a matrix of n_inds x (k_lands*m_dim) [that is a classical matrix from ...morphoJ ,for example] for example (in two dimension, but it can be in 3d) n1 x1 y1 x2 y2 ....xn yn n2 n3 n... in an array of n matrices structured in k_lands x m_dim to be used for existing gpa R routines I tried: ew<-matrix(n°inds,n°lands*n°dim) er<-er<-as.vector(t(ew)) er2<-array(er,dim=c(n°lands,n°dim,n°inds)) Maybe in past messages of morphmet there in the answer, I took a look...but I did not find the proper solution thankyou in advance Paolo -- Paolo Piras Center for Evolutionary Ecology and Dipartimento di Scienze Geologiche, Università Roma Tre Largo San Leonardo Murialdo, 1, 00146 Roma Tel: +390657338000 email: [email protected] -- Paolo Piras Center for Evolutionary Ecology and Dipartimento di Scienze Geologiche, Università Roma Tre Largo San Leonardo Murialdo, 1, 00146 Roma Tel: +390657338000 email: [email protected]
