Martin Batholdy
2011-Oct-05 16:20 UTC
[R] converting 3D array to a data-frame (with coordinate-columns x, y, z)
Hi, I am still struggling with three dimensional arrays. Now I would like to convert a three dimensional array into a data-frame with the coordinate-columns: x, y, z and a value-column. And I definitely don't want to loop over every element, since this would be very resource intensive for the actual data-set. Are there any specific functions that are helpful for this task? example-array: x <- array(1:27, dim=c(3,3,3,1)) thanks!
R. Michael Weylandt
2011-Oct-05 16:23 UTC
[R] converting 3D array to a data-frame (with coordinate-columns x, y, z)
reshape::melt does this I think Michael On Wed, Oct 5, 2011 at 12:20 PM, Martin Batholdy <batholdy at googlemail.com> wrote:> Hi, > > > I am still struggling with three dimensional arrays. > > Now I would like to convert a three dimensional array into a data-frame with the coordinate-columns: x, y, z and a value-column. > > And I definitely don't want to loop over every element, since this would be very resource intensive for the actual data-set. > > > Are there any specific functions that are helpful for this task? > > > > example-array: > > x <- array(1:27, dim=c(3,3,3,1)) > > > > thanks! > ______________________________________________ > R-help at 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. >
frauke
2012-Sep-24 16:12 UTC
[R] converting 3D array to a data-frame (with coordinate-columns x, y, z)
Hi Martin, did you ever find a solution? I have the a similar problem because I want to do a regression where the independent and dependent variables are matrices of measurements. I can run loops to make each matrix one very long vector, but I m looking for a more elegant solution. Thank you! Frauke -- View this message in context: http://r.789695.n4.nabble.com/converting-3D-array-to-a-data-frame-with-coordinate-columns-x-y-z-tp3875064p4644022.html Sent from the R help mailing list archive at Nabble.com.