merge_by_partition: Merge matrix rows/columns by a partition

Description Usage Arguments Value

View source: R/merge_by_partition.R

Description

Merge matrix rows/columns according to a partition of row indices

Usage

1
2
3
4
5
6
7
merge_by_partition(
  m,
  partition,
  agg = Matrix::colSums,
  n_cpu = 1,
  check = FALSE
)

Arguments

m

A matrix

partition

A list of integer vectors, which makes a full partition of the rows of m

agg

Function. The function that will be called to merge the rows. Must return a matrix with the same number of columns and as many rows as needed. Default is colSums.

n_cpu

Integer. Number of cores to be used for the calculation, passed to the parameter mc.cores of the function mclapply. Default is 1 which means the "regular" lapply will be used.

check

Logical. Should the function check if the provided partition is valid? Default is FALSE.

Value

A new matrix with less (or more?) rows, depending on the aggregation function.


ytoren/simscaleR documentation built on April 17, 2021, 12:32 p.m.