Vectorize.function: Vectorize a multidimensional Function

View source: R/function.R

Vectorize.functionR Documentation

Vectorize a multidimensional Function

Description

Vectorize a d-dimensional (input) function, in the same way that base::Vectorize for 1-dimensional functions.

Usage

Vectorize.function(fun, dim, ...)

Arguments

fun

'dim'-dimensional function to Vectorize

dim

dimension of input arguments of fun

...

optional args to pass to 'Apply.function()', including .combine, .lapply, or optional args passed to 'fun'.

Value

a vectorized function (to be called on matrix argument, on each row)

Examples

f = function(x)x[1]+1; f(1:10); F = Vectorize.function(f,1);
F(1:10); #F = Vectorize(f); F(1:10);

f2 = function(x)x[1]+x[2]; f2(1:10); F2 = Vectorize.function(f2,2);
F2(cbind(1:10,11:20));

DiceView documentation built on Jan. 17, 2023, 1:09 a.m.