averageColumns | R Documentation |
Rearranges and averages columns according to by
.
averageColumns(x, by = NULL, func = function(x) {
mean(x, na.rm = TRUE)
})
x |
the matrix whose columns should be averaged. |
by |
an integer or vector by which to average and/or rearrange columns. |
func |
the function to apply to the result. Default: mean with removing NAs. |
Returns a vector or matrix of averaged columns.
Rehrauer, Hubert
Schmid, Peter
m1 = matrix(1:20,5)
rownames(m1) = 1:5
m2 = averageColumns(m1,1)
m3 = averageColumns(m1,c(4,2,3,1))
m4 = averageColumns(m1,c(1,1,2,2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.