bigmemory icon indicating copy to clipboard operation
bigmemory copied to clipboard

rbind-like function?

Open VincentDamotte opened this issue 9 years ago • 6 comments

Hi, I am wondering is there is rbind-like function, as it seems that rbind() can not handle big.matrix objects Thanks Vincent

VincentDamotte avatar May 09 '16 22:05 VincentDamotte

There is currently not an rbind function. Since bigmemory allocates contiguous blocks of memory, this can be very expensive. It is currently up to the user to implement rbind by allocating a new big.mattrix object with the appropriate number of columns and copy the contents of the source matrices to the new big.matrix.

kaneplusplus avatar May 11 '16 19:05 kaneplusplus

I have seen this come up before, perhaps a simple wrapper that accomplishes this automatically (with proper documentation noting what it does of course) for rbind/cbind methods? However it may be more appropriate for a biganalytics issue than bigmemory?

cdeterman avatar Jun 02 '16 15:06 cdeterman

Either one is fine with me. I might lean toward putting it into bigmemory. Also you are correct that requests for this functionality are not uncommon.

kaneplusplus avatar Jun 02 '16 19:06 kaneplusplus

@kaneplusplus how would i do the allocation and the copy?

mcooganj avatar Dec 15 '18 00:12 mcooganj

  1. Create a big.matrix object with the appropriate dimensions using init = NULL.
  2. For each of the arguments to cbind (or rbind), copy the values into the appropriate locations.

kaneplusplus avatar Dec 17 '18 21:12 kaneplusplus

For this to be implemented efficiently, I think, it would be first needed to implement this:

library(bigmemory)
a <- big.matrix(2, 2, init = 1)
b <- big.matrix(4, 2)
b[1:2, ] <- a

Would be SOOOOO useful.

privefl avatar Dec 17 '18 22:12 privefl