[R] Reshaping an array - how does it work in R

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Fri Mar 18 23:11:38 CET 2016

R always makes a copy for this kind of operation. There are some operations that don't make copies, but I don't think this one qualifies. 

Sent from my phone. Please excuse my brevity.

On March 18, 2016 2:28:35 PM PDT, Roy Mendelssohn - NOAA Federal <roy.mendelssohn at noaa.gov> wrote:
>Hi All:
>I am working with a very large array.  if noLat is the number of
>latitudes, noLon the number of longitudes and noTime the number of 
>time periods, the array is of the form:
>myData[noLat, no Lon, noTime].
>It is read in this way because that is how it is stored in a (series)
>of netcdf files.  For the analysis I need to do, I need instead the
>myData[noLat*noLon, noTime].  Normally this would be easy:
>myData<- array(myData,dim=c(noLat*noLon,noTime))
>My question is how does this command work in R - does it make a copy of
>the existing array, with different indices for the dimensions, or does
>it just redo the indices and leave the given array as is?  The reason
>for this question is my array is 30GB in memory, and I don’t have
>enough space to have a copy of the array in memory.  If the latter I
>will have to figure out a work around to bring in only part of the data
>at a time and put it into the proper locations.
>"The contents of this message do not reflect any position of the U.S.
>Government or NOAA."
>Roy Mendelssohn
>Supervisory Operations Research Analyst
>Environmental Research Division
>Southwest Fisheries Science Center
>***Note new address and phone***
>110 Shaffer Road
>Santa Cruz, CA 95060
>Phone: (831)-420-3666
>Fax: (831) 420-3980
>e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/
>"Old age and treachery will overcome youth and skill."
>"From those who have been given much, much will be expected" 
>"the arc of the moral universe is long, but it bends toward justice"
>-MLK Jr.
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list