apply2d: Apply a function to a combination of vectors

Description Usage Arguments Value Author(s) See Also Examples

View source: R/utils3d.R

Description

applies a (non-vectorized) function to a combination of vectors; substitute for outer

Usage

1
apply2d(fun, x, y, ..., use_plyr = TRUE, .progress="none")

Arguments

fun

a function of two arguments (or a character string such as "*")

x

first vector

y

second vector

...

additional arguments to fun

use_plyr

use methods from the plyr package?

.progress

progress bar type ("none", "text", "tk","win": see create_progress_bar)

Value

a matrix of the function applied to the combinations of the vector values

Author(s)

Ben Bolker

See Also

outer

Examples

1
2
3
outer(1:3,1:3)
## this example would work with outer() too
apply2d("*",1:3,1:3)

Example output

     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    2    4    6
[3,]    3    6    9
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    2    4    6
[3,]    3    6    9

emdbook documentation built on May 2, 2019, 9:41 a.m.