Learn R Programming

emdbook (version 1.3.2.1)

apply2d: Apply a function to a combination of vectors

Description

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

Usage

apply2d(fun, x, y, ...)

Arguments

fun
a function of two arguments (or a character string such as "*")
x
first vector
y
second vector
...
additional arguments to fun

Value

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

See Also

outer

Examples

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

Run the code above in your browser using DataLab