powered by
This is a generic function that can be used to find mean, variance, sum or other operations according to some index imposed on the matrix or vector.
fun.mApply(X, INDEX, FUN = NULL, ..., simplify = TRUE)
If FUN returns more than one number, fun.mApply returns a matrix with rows corresponding to unique values of INDEX.
FUN
fun.mApply
INDEX
Matrix with n rows.
Vector or list of vectors of length n.
Function to operate on submatrices of X by INDEX
X
Arguments to function.
Set as TRUE by default, see sapply fo details.
TRUE
sapply
Tony Plate
# Finding the row medians of a matrix (matrix(1:20,nrow=5)) fun.mApply(matrix(1:20,nrow=5),list(1:5),median)
Run the code above in your browser using DataLab