Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fun.mApply

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 X by INDEX

...

Arguments to function.

simplify

Set as TRUE by default, see sapply fo details.

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)

GLDEX

Fitting Single and Mixture of Generalised Lambda Distributions (RS and FMKL) using Various Methods

v2.0.0.7
GPL (>= 3)
Authors
Steve Su, with contributions from: Diethelm Wuertz, Martin Maechler and Rmetrics core team members for low discrepancy algorithm, Juha Karvanen for L moments codes, Robert King for gld C codes and starship codes, Benjamin Dean for corrections and input in ks.gof code and R core team for histsu function.
Initial release
2020-02-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.