split.HDF5Matrix: Split an HDF5Matrix into a list of blocks

View source: R/S3_operations.R

split.HDF5MatrixR Documentation

Split an HDF5Matrix into a list of blocks

Description

S3 method of base::split() for HDF5Matrix objects. Divides the matrix into blocks along rows (default) or columns.

Provide exactly ONE of n_blocks or block_size.

Usage

## S3 method for class 'HDF5Matrix'
split(
  x,
  f = NULL,
  drop = FALSE,
  n_blocks = -1L,
  block_size = -1L,
  bycols = FALSE,
  out_group = "SPLIT",
  out_dataset = NULL,
  overwrite = FALSE,
  ...
)

Arguments

x

An HDF5Matrix.

f

Ignored (kept for S3 signature compatibility).

drop

Ignored (S3 compatibility).

n_blocks

Integer. Number of (roughly equal) blocks; -1 = unused.

block_size

Integer. Max rows (or cols) per block; -1 = unused.

bycols

Logical. If TRUE, split by columns (default = by rows).

out_group

Character. HDF5 group for output blocks (default "SPLIT").

out_dataset

Character or NULL. Base dataset name.

overwrite

Logical. Overwrite existing blocks (default FALSE).

...

Ignored.

Value

Named list of HDF5Matrix objects: block_0, block_1, …

Examples



fn <- tempfile(fileext = ".h5")
X  <- hdf5_create_matrix(fn, "data/X", data = matrix(rnorm(2000000), 20000, 100))

X      <- hdf5_matrix( fn, "data/X")   # 20000 × 1000
blocks <- split(X, n_blocks = 4)             # 4 row-blocks of ~5000 rows each



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