Roy, I have implemented a Ruby Gem (SciCom) with exactly your use case in mind. SciCom is based on Renjin, an R interpreter for the JVM. So, this reply is about R, but not about GnuR. If this is not proper behavior, please let me know. I?ve looked at the posting guidelines and it seems to be ok. SciCom interfaces with another Ruby Gem: MDArray. MDArray is a multidimensional array class that is based on NetCDF-Java. It can read netcdf files and store them in a multidimensional array. MDArray can be reshaped and also sliced and diced as you can do with NetCDF. Reshaping an MDArray does not require any copying, it is just index manipulations. An MDArray can then be "send" to SciCom. This is not really sending, since there is no data copying either and the array is just wrapped in such a way that it can be used in Renjin. In Renjin you could use normal R functions to process this data and do your analysis. The data in SciCom can thus be viewed either as an R array, to which R sematics apply and reshaping will copy the data, or as an MDArray, and reshaping and slicing/dicing does not do any copying. It is up to the developer to be careful how to see the data and operate on it. There are however two showstoppers: i) Renjin does not load all CRAN packages yet. So, there is a good chance that if you need a package for your PCA analysis, that this will not be loaded; ii) SciCom/Renjin do not support any graphics such as plot/ggplot. References: Renjin: http://www.renjin.org/ NetCDF-Java: http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/ MDArray: https://github.com/rbotafogo/mdarray/wiki SciCom: https://github.com/rbotafogo/scicom https://github.com/rbotafogo/scicom/wiki/A-(not-so)-Short-Introduction-to-SciCom -- Rodrigo Botafogo [[alternative HTML version deleted]]
Roy Mendelssohn - NOAA Federal
2016-Mar-21 19:01 UTC
[R] Reshaping an array - how does it work in R
Thanks for the info, but I will stay with regular R. Work -arounds for what I want to do just took some thought and programming, I just didn?t know if R copied the array or just manipulated indices, and given the size of the array I am memory limited. This gets into the old thing of whether it is better to pass arrays by reference or value. As an old Fortran programmer, that is one nice thing that could be done in Fortran - since arrays are passed by reference, the indices could be manipulated in the same memory space by passing to a subroutine, or through an equivalence statement. But all of these things have trade-offs. -Roy> On Mar 21, 2016, at 7:26 AM, Rodrigo Botafogo <rodrigo at rodrigobotafogo.com> wrote: > > Roy, > > I have implemented a Ruby Gem (SciCom) with exactly your use case in mind. > SciCom is based on Renjin, an R interpreter for the JVM. So, this reply is > about R, but not about GnuR. If this is not proper behavior, please let me > know. I?ve looked at the posting guidelines and it seems to be ok. > > SciCom interfaces with another Ruby Gem: MDArray. MDArray is a > multidimensional array class that is based on NetCDF-Java. It can read > netcdf files and store them in a multidimensional array. MDArray can be > reshaped and also sliced and diced as you can do with NetCDF. Reshaping an > MDArray does not require any copying, it is just index manipulations. > > An MDArray can then be "send" to SciCom. This is not really sending, since > there is no data copying either and the array is just wrapped in such a way > that it can be used in Renjin. In Renjin you could use normal R functions > to process this data and do your analysis. > > The data in SciCom can thus be viewed either as an R array, to which R > sematics apply and reshaping will copy the data, or as an MDArray, and > reshaping and slicing/dicing does not do any copying. It is up to the > developer to be careful how to see the data and operate on it. > > There are however two showstoppers: i) Renjin does not load all CRAN > packages yet. So, there is a good chance that if you need a package for > your PCA analysis, that this will not be loaded; ii) SciCom/Renjin do not > support any graphics such as plot/ggplot. > > References: > > Renjin: http://www.renjin.org/ > NetCDF-Java: > http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/ > MDArray: https://github.com/rbotafogo/mdarray/wiki > SciCom: > https://github.com/rbotafogo/scicom > > https://github.com/rbotafogo/scicom/wiki/A-(not-so)-Short-Introduction-to-SciCom > > -- > Rodrigo Botafogo > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS 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.