| avgFacLvls {ChemoSpec} | R Documentation |
avgFacLvls takes a matrix and calculates the column means for
each level of each factor given. It then replaces the original matrix rows
with the means corresponding to the factor/level memership of a particular
sample (row).
avgFacLvls(matrix, fac)
matrix |
A matrix. |
fac |
A vector of character strings with length = |
A matrix whose rows are composed of the column means for each level of the factor.
Matthew J. Keinsley and Bryan A. Hanson, DePauw University.
https://github.com/bryanhanson/ChemoSpec
aov_pcaSpectra for full details.
M1 <- matrix(rnorm(100), nrow = 20, byrow = TRUE)
facs <- factor(c(rep("A",5), rep("B",5), rep("C", 5), rep("D", 5)))
M2 <- avgFacLvls(M1, fac = facs)