cbind.HDF5Matrix: Column-bind HDF5Matrix objects

View source: R/S3_bind.R

cbind.HDF5MatrixR Documentation

Column-bind HDF5Matrix objects

Description

Binds two or more HDF5Matrix objects by columns (appending columns to the right). All matrices must have the same number of rows. The operation is performed block-wise on disk.

Usage

## S3 method for class 'HDF5Matrix'
cbind(
  ...,
  deparse.level = 1,
  out_file = NULL,
  out_group = NULL,
  out_dataset = NULL,
  block_rows = 1000L,
  overwrite = FALSE,
  compression = NULL
)

Arguments

...

One or more HDF5Matrix objects (all with the same number of rows). Plain R matrices are also accepted and will be written to a temporary HDF5 dataset automatically.

deparse.level

Ignored (for S3 compatibility with base::cbind).

out_file

Output HDF5 file. NULL = same file as first argument.

out_group

Output group. NULL = "BIND".

out_dataset

Output dataset. NULL = auto-generated name.

block_rows

Integer. Rows per I/O block (default 1000).

overwrite

Logical. Overwrite existing output. Default FALSE.

compression

Integer (0-9) or NULL. gzip compression level for the result datasets. NULL uses the global option set by hdf5matrix_options (default 6). Use 0 to disable compression (faster for benchmarks).

Value

HDF5Matrix pointing to the combined dataset.

Examples



fn <- tempfile(fileext = ".h5")

A  <- hdf5_create_matrix(fn, "grp/A", data = matrix(rnorm(100), 10, 10))
B  <- hdf5_create_matrix(fn, "grp/B", data = matrix(rnorm(100), 10, 10))

A <- hdf5_matrix(fn, "grp/A")
B <- hdf5_matrix(fn, "grp/B")
C <- cbind(A, B)          # columns of A followed by columns of B
dim(C)                    # nrow(A) x (ncol(A) + ncol(B))

hdf5_close_all()
unlink(fn)




BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.