Learn R Programming

BigDataStatMeth (version 2.0.3)

colMeans: 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 HDF5Matrix colMeans( x, na.rm = FALSE, dims = 1, paral = NULL, wsize = NULL, threads = NULL, save_to = NULL, overwrite = TRUE, ... )

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

Value

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

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

Examples

Run this code
# \donttest{
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)
# }

Run the code above in your browser using DataLab