add.cols, rm.cols {bigmemory} | R Documentation |
Add and remove columns of a big.matrix
(only valid for non-shared matrices).
add.cols(x, ncol = 1, init = 0, column.names = NULL) rm.cols(x, remove.columns)
x |
a big.matrix . |
ncol |
the number of columns to add. |
remove.columns |
a vector of integer indices or variable names to remove. |
init |
a scalar value for initializing the column(s); this may not be a vector or a matrix of values. |
column.names |
a vector of ncols names (optional). |
This function adds and removes columns of a big.matrix
with no memory overhead. Note that these operations are not
permitted if the matrix is in shared memory (if is.shared(x)
is
TRUE
).
None; the big.matrix
, x
, is actually modified.
John W. Emerson and Michael J. Kane
x <- big.matrix(5, 2, init=1) colnames(x)=c("alpha", "beta") add.cols(x, 1, column.names="gamma") x[,] rm.cols(x, 2) x[,] add.cols(x, 2, column.names=c("jay", "mike")) rm.cols(x, "alpha") x[,]