Learn R Programming

bigstep (version 0.7.4)

combineBigMatrices: Combine, transpose big matrices and change colnames

Description

Combine and/or transpose big matrices and write to a file with new names of columns

Usage

combineBigMatrices(X, Z = NULL, file.out = "XZ.txt", transX = FALSE,
  transZ = FALSE, new.names = NULL, maxp = 1e+07, verbose = TRUE)

Arguments

X

an object of class big.matrix.

Z

an object of class big.matrix. Specify if you want to combine matrices.

file.out

a character string. The name of the output file.

transX

a logical. If TRUE, the matrix X will be transposed.

transZ

a logical. If TRUE, the matrix Z will be transposed.

new.names

a vector of strings. Specify if you want to change names of variables.

maxp

a numeric. If X is big, it will be splitted into parts with maxp elements. It will not change results, but it is necessary if your computer does not have enough RAM. Set to a lower value if you still have problems.

verbose

a logical. Set FALSE if you do not want to see any information during the selection procedure.

Value

A numeric, a number of variables successfully written.

Examples

Run this code
# NOT RUN {
library(bigmemory)
X <- matrix(sample(0:2, 20, replace=TRUE), 2, 10)
Z <- matrix(sample(0:2, 20, replace=TRUE), 2, 10)
write.table(X, "X.txt", col.names=FALSE, row.names=FALSE)
write.table(Z, "Z.txt", col.names=FALSE, row.names=FALSE)
X <- read.big.matrix("X.txt", sep=" ", type="char")
Z <- read.big.matrix("Z.txt", sep=" ", type="char")
# if it is possible, set type="char", reading will be quicker
names <- c("X1", "X2", "Z1", "Z2")
combineBigMatrices(X, Z, transX=TRUE, transZ=TRUE, new.names=names)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab