multiapply {maDB}R Documentation

Apply a function to two arrays

Description

multiapply This function allows to apply functions that need two input parameters row wise or column wise to two arrays.

Usage

multiapply(a,b,MARGIN,FUN,...)

Arguments

a An array wich rows or columns should be submitted to the function.
b An array wich rows or columns should be submitted to the function, the argument a will be passed as first argument to the function while the argument b will be passed as the second one.
MARGIN Like the MARGIN argument in the apply function, 1 means submit the rows to the function, 2 the columns.
FUN The function that should be applied. Any function that needs two input parameters.
... Additional parameters for the function FUN.

Details

Like the apply function this function can be used to apply functions to the rows or columns of a matrix, without having to write for loops. If the result of the function FUN is numeric or a character the function returns an array containing the results, otherwise a list with the output of the function FUN.

Author(s)

Johannes Rainer

References

See Also

apply

Examples

## creating two arrays
a <- matrix(ncol=3,nrow=3)
a[1,] <- c(1,2,2)
a[2,] <- c(3,2,3)
a[3,] <- c(2,2,2)
b <- matrix(ncol=5,nrow=3)
b[1,] <- c(8,8,6,8,10)
b[2,] <- c(2,3,3,2,3)
b[3,] <- c(1,1,1,1,2)

## now we perform a wilcox unpaired test for each row.
multiapply(a=a,b=b,MARGIN=1,FUN=wilcox.test,paired=FALSE)

[Package maDB version 1.8.0 Index]