rbind-like function?
Hi, I am wondering is there is rbind-like function, as it seems that rbind() can not handle big.matrix objects Thanks Vincent
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.
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?
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 how would i do the allocation and the copy?
- Create a
big.matrixobject with the appropriate dimensions usinginit = NULL. - For each of the arguments to
cbind(orrbind), copy the values into the appropriate locations.
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.