aggregate_by_vector: Aggreagate quantitative features.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/aggregate.R

Description

This function takes a matrix of quantitative features x and a factor (of length equal to nrow(x)) defining subsets, and applies a user-defined function to aggregate each subset into a vector of quantitative values.

User-defined functions must thus return a vector of length equal to ncol(x). Examples thereof are

Usage

1
aggregate_by_vector(x, INDEX, FUN, ...)

Arguments

x

A matrix of mode numeric.

INDEX

A factor of length nrow(x).

FUN

A function to be applied to the subsets of x.

...

Additional arguments passed to FUN.

Value

A new matrix of dimensions ncol(x) and length(INDEX) with dimnames equal to colnames(x) and INDEX.

Author(s)

Laurent Gatto

See Also

Other Quantitative feature aggregation: colCounts(), medianPolish(), robustSummary()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
x <- structure(c(10.3961935744407, 17.1663715212693, 14.1027587989326,
                12.850349037785, 10.6379251053134, 7.52885076885599,
                3.91816118984218, 11.1339832690524, 16.5321471730746,
                14.1787908569268, 11.9422579479634, 11.5154097311056,
                7.69906817878979, 3.97092153807337, 11.9394664781386,
                15.3791100898935, 14.2409281956285, 11.2106867261254,
                12.2958526883634, 9.00858488668671, 3.83120129974963,
                12.9033445520186, 14.375814954807, 14.1617803596661,
                10.1237981632645, 13.3390344671153, 9.75719265786117,
                3.81046169359919),
              .Dim = c(7L, 4L),
              .Dimnames = list(c("X1", "X27", "X41", "X47", "X52",
                                 "X53", "X55"),
                               c("iTRAQ4.114", "iTRAQ4.115",
                                 "iTRAQ4.116", "iTRAQ4.117")))
x

k <- factor(c("B", "E", "X", "E", "B", "B", "E"))

aggregate_by_vector(x, k, colMeans)
aggregate_by_vector(x, k, robustSummary)
aggregate_by_vector(x, k, medianPolish)

MsCoreUtils documentation built on Nov. 8, 2020, 10:59 p.m.