apply {matter} | R Documentation

## Apply Functions Over “matter” Matrices

### Description

An implementation of `apply` for `matter_mat`, `sparse_mat` and `virtual_mat` matrices.

### Usage

    ## S4 method for signature 'matter_mat'
    apply(X, MARGIN, FUN, ..., BPPARAM = bpparam(), simplify = TRUE)

    ## S4 method for signature 'sparse_mat'
    apply(X, MARGIN, FUN, ..., BPPARAM = bpparam(), simplify = TRUE)

    ## S4 method for signature 'virtual_mat'
    apply(X, MARGIN, FUN, ..., BPPARAM = bpparam(), simplify = TRUE)

### Arguments

`X` | A `matter` matrix-like object.
`MARGIN` | Must be 1 or 2 for `matter_mat` matrices, where ‘1’ indicates rows and ‘2’ indicates columns. The dimension names can also be used if `X` has `dimnames` set.
`FUN` | The function to be applied.
`...` | Additional arguments to be passed to `FUN`.
`BPPARAM` | An optional instance of `BiocParallelParam`. See documentation for `bplapply`.
`simplify` | Should the result be simplified?

### Details

Because `FUN` must be executed by the interpreter in the appropriate R environment, the full row or column will be loaded into memory. The `chunksize` of `X` is ignored. For summary statistics, functions like `colMeans` and `rowMeans` offer greater control over memory pressure. When performed in parallel, the `matter` metadata is serialized to each R session, so all workers must be able to access the data via the same `paths()`.

### Value

See `apply` for details.

### Warning

Applying a function over the rows of a column-major matrix (e.g., `matter_matc`) or over the columns of a row-major matrix (e.g., `matter_matr`) may be very slow.

### Author(s)

Kylie A. Bemis

### See Also

`apply`

### Examples

    register(SerialParam())

    x <- matter(1:100, nrow=10, ncol=10)

    apply(x, 2, summary)

[Package matter version 1.20.0 Index]