colMeans: Column and row means for HDF5Matrix

View source: R/S3_aggregations.R

colMeansR Documentation

Column and row means for HDF5Matrix

Description

Block-wise computation of column and row means without loading the full matrix into RAM.

Usage

colMeans(x, na.rm = FALSE, dims = 1L, ...)

rowMeans(x, na.rm = FALSE, dims = 1L, ...)

## S3 method for class 'HDF5Matrix'
colMeans(
  x,
  na.rm = FALSE,
  dims = 1,
  paral = NULL,
  wsize = NULL,
  threads = NULL,
  save_to = NULL,
  overwrite = TRUE,
  ...
)

## S3 method for class 'HDF5Matrix'
rowMeans(
  x,
  na.rm = FALSE,
  dims = 1,
  paral = NULL,
  wsize = NULL,
  threads = NULL,
  save_to = NULL,
  overwrite = TRUE,
  ...
)

Arguments

x

An HDF5Matrix object.

na.rm

Ignored (included for compatibility with the base generic).

dims

Ignored (included for compatibility with the base generic).

...

Ignored.

paral

Logical or NULL. Enable OpenMP parallelisation.

wsize

Integer or NULL. Block size for HDF5 reads (NULL = auto).

threads

Integer or NULL. Number of OpenMP threads (NULL = auto).

save_to

Where to save the result (see Details). NULL returns a plain R vector; a character string "group/dataset" saves in the same file as x; a named list list(file = "f.h5", path = "group/dataset") saves in a different file. In both non-NULL cases an HDF5Matrix handle is returned.

overwrite

Logical. Overwrite an existing dataset at save_to? (Currently always TRUE when save_to is not NULL.)

Value

A numeric vector (when save_to = NULL) or an HDF5Matrix handle to the persisted result.

Examples


tmp <- tempfile(fileext = ".h5")
X <- hdf5_create_matrix(tmp, "data/M", data = matrix(rnorm(200), 20, 10))
cm <- colMeans(X)
hdf5_close_all()
unlink(tmp)



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