aggregateCol: Aggregate columns

View source: R/aggregateCol.R

aggregateColR Documentation

Aggregate columns

Description

aggregateCol() performs summary statistics on a specific subset of columns.

Usage

aggregateCol(data, grp, names_aggreg = NULL, FUN = sum, ...)

Arguments

data

a data frame.

grp

an integer vector, one value per data column. Integers are used to group data columns, column with the same integer will be pooled together. Any integer is a valid group, 0 indicates that the column must be unchanged, NA removes columns.

names_aggreg

column names for aggregated columns.

FUN

a function to be applied to all groups of columns.

...

further arguments to be passed to FUN.

Details

grp is an integer vector, whose length is the number of columns of the input data frame, is used to assign a group to each column that explicit the sub-setting. Furthermore columns can be either kept as is using 0 or discarded using NA.

Value

A data frame with the grouped columns.

See Also

stats::aggregate() base::split

Examples

mat1 <- matrix(1:70,10)
grp1 <- c(NA,0, 1, 1, 2, 2, 2)
aggregateCol(mat1, grp1, FUN = mean)

letiR/letiRmisc documentation built on Sept. 11, 2022, 12:43 a.m.