sumnrow: Sum every nth row of a matrix and name the resulting rows

View source: R/matrix_sum.R

sumnrowR Documentation

Sum every nth row of a matrix and name the resulting rows

Description

Groups a matrix by rows, summing every Nth row. Matrix should be multiple of N.

Usage

sumnrow(df, N, row_names = NULL)

Arguments

df

A matrix with named rows and columns.

N

Integer, specifying the resulting number or rows.

row_names

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

Value

A matrix with N rows, where each row is the sum of every Nth row of the original matrix.

Examples

wio <- make_wio("wiodtest", quiet = TRUE)
sumnrow(wio$Y, wio$dims$N, paste0("WLD", "_",
        gsub("^D", "", wio$names$n_names)))

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