Aggreagate quantitative features.
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
medianPolish()
to fits an additive model (two way decomposition)
using Tukey's median polish_ procedure using
stats::medpolish()
;
robustSummary()
to calculate a robust aggregation using
MASS::rlm()
;
base::colMeans() to use the mean of each column;
base::colSums()
to use the sum of each column;
matrixStats::colMedians() to use the median of each column.
aggregate_by_vector(x, INDEX, FUN, ...)
x |
A |
INDEX |
A |
FUN |
A |
... |
Additional arguments passed to |
A new matrix
of dimensions ncol(x)
and length(INDEX)
with dimnames
equal to colnames(x)
and INDEX
.
Laurent Gatto
Other Quantitative feature aggregation:
colCounts()
,
medianPolish()
,
robustSummary()
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.