split_apply: Apply a function to groups of columns

Description Usage Arguments Value See Also Examples

View source: R/split_apply.R

Description

Divide the columns of a data frame by the groups defined in FACTOR, apply the function FUN to each subgroup and then join the resulting vectors in a new data frame.

Usage

1
split_apply(X, FUN, FACTOR, SEP = ".", ...)

Arguments

X

An object coercible to data frame.

FUN

A function that receives a data frame and returns a vector.

FACTOR

A <e2><80><98>factor<e2><80><99> in the sense that as.factor(FACTOR) defines the grouping, or a list of such factors in which case their interaction is used for the grouping.

SEP

String to construct the new level labels by joining the constituent ones. Defaults to ".".

...

Optional arguments to FUN.

Value

A data frame, result of the split-apply-combine process.

See Also

split, lapply

Examples

1
2
3
4
5
6
data(geneData, geneCovariate, package='Biobase')
gData <- head(geneData, n=10)

meanExprs <- split_apply(log2(gData), FUN=rowMeans,
                         FACTOR=geneCovariate[c('sex','type')], na.rm=TRUE)
summary(meanExprs)

csbl-usp/collapseR documentation built on May 6, 2019, 8:32 p.m.