fun.mApply {GLDEX} | R Documentation |
Applying functions based on an index for a matrix.
Description
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.
Usage
fun.mApply(X, INDEX, FUN = NULL, ..., simplify = TRUE)
Arguments
X |
Matrix with n rows. |
INDEX |
Vector or list of vectors of length n. |
FUN |
Function to operate on submatrices of |
... |
Arguments to function. |
simplify |
Set as |
Value
If FUN
returns more than one number, fun.mApply
returns a matrix
with rows corresponding to unique values of INDEX
.
Author(s)
Tony Plate
Examples
# Finding the row medians of a matrix (matrix(1:20,nrow=5))
fun.mApply(matrix(1:20,nrow=5),list(1:5),median)
[Package GLDEX version 2.0.0.9.3 Index]