mat_apply: mat apply

Description Usage Arguments Details Examples

View source: R/mat_apply.R

Description

Apply a function to each element in an input and return an arbitrary dimensioned array.

Usage

1
  mat_apply <- function(vec, fun)

Arguments

vec

vector of inputs fed into fun

fun

a function to call for each input of vec

Details

This function returns an array with first dimension of length(vec) provided length(vec) > 1–the first dimension indexes over the length(vec) outputs.

Examples

1
2
  # returns a 10 x 3 x 3 array. ret[i,,] contains i*diag(3).
  ret <- mat_apply(1:10, function(i){ i*diag(3) })

dcbdan/s525 documentation built on May 19, 2019, 10:48 p.m.