Learn R Programming

exvatools (version 0.9.0)

sumncol: 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)

Value

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

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.

Examples

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

Run the code above in your browser using DataLab