sumncol: Sum every nth column of a matrix and name the resulting...

View source: R/matrix_sum.R

sumncolR Documentation

Sum every nth column of a matrix and name the resulting columns

Description

Groups a matrix by columns, summing every Nth column. Matrix should be multiple of N.

Usage

sumncol(df, N, col_names = NULL)

Arguments

df

A matrix with named rows and columns.

N

Integer, specifying the resulting number of columns.

col_names

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

Value

A matrix with N columns, where each columns is the sum of every Nth column of the original matrix.

Examples

wio <- make_wio("wiodtest", quiet = TRUE)
sumncol(wio$Yfd, wio$dims$FD, paste0("WLD", "_", wio$names$fd_names))

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