add.cols, rm.cols {bigmemory}R Documentation

Add and remove columns of a “big.matrix”.

Description

Add and remove columns of a big.matrix (only valid for non-shared matrices).

Usage

add.cols(x, ncol = 1, init = 0, column.names = NULL)
rm.cols(x, remove.columns)

Arguments

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).

Details

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).

Value

None; the big.matrix, x, is actually modified.

Author(s)

John W. Emerson and Michael J. Kane

See Also

big.matrix

Examples

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[,]

[Package bigmemory version 2.3 Index]