On Aug 28, 2011, at 5:09 PM, marco wrote:

Hi everyone,
have a small problem trying to converting a dataset in matrix form to an
array.
Specifically: data include 3D measurement -x,y,z of 59 points in 36 objects.
They are stored as a matrix (x) of 2124 rows and 3 columns.
What I want to do is to extract each subject's dataset using an array (b).
Accordingly, I tried the following command:

b<-array(a,c(59,3,36)).

The problem is that the resulting array for some strange reason change the
order of the original data.

Not for a "strange reason". The 59 elements in b in column-1 would be the same in both , but you don't seem to realize that the 60th through the 118th elements in your original matrix were also all in the x- column. You have now effectively moved those values to what you were thinking to use as the y-column.

Specifically, I noticed that, for example, in the first subject, the x y z
values of the first point are the x values of the first 3 subjects.

You should have kept the last dimension the same and redimension the object/points indexing by factoring the 2124 rows into what will become columns and row and leave the xyz coordinates "at the end". I think that redimensioning as b<-array(a,c(59, 36, 3)) would have re- folded it sensiblyly. So the b[n,m,] call would retrieve xyz- coordinates from the n-th point of the m-th object.




Did I perhaps missed something?
Thanks in advance



--
View this message in context: 
http://r.789695.n4.nabble.com/converting-matrix-in-array-tp3775025p3775025.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org 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.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org 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.

Reply via email to