sumgrows: Sum groups of rows of a matrix and name the resulting rows

View source: R/matrix_sum.R

sumgrowsR Documentation

Sum groups of rows of a matrix and name the resulting rows

Description

Groups a matrix by rows, summing blocks of rows of size n each. Matrix rows should be multiple of n.

Usage

sumgrows(df, n, row_names = NULL)

Arguments

df

A matrix with named rows and columns.

n

Integer, specifying the size of each group.

row_names

String vector of length n, with names to assign to the resulting rows.

Value

A matrix where each row is the sum of groups of n rows of the original matrix.

Examples

wio <- make_wio("wiodtest", quiet = TRUE)
sumgrows(wio$Y, wio$dims$N, wio$names$g_names)

exvatools documentation built on May 29, 2024, 6:46 a.m.