eOuter: Extend outer product.

Description Usage Arguments Details Value See Also Examples

View source: R/expandFunctions.R

Description

Extends outer {base} outer(x,y,FUN) to include functions FUN(x,y,...) where the first argument of FUN is a vector but the second argument must be a scalar.

Usage

1
eOuter(x, y, FUN, ...)

Arguments

x

Vector, with the same function as in outer {base}. Each value will correspond to a row in the return matrix.

y

Vector. Each element in the vector corresponds to a column in the return matrix.

FUN

Function. x and y will be the first and second arguments. Unlike outer, however, while a vector can be the first argument, FUN might only allow one value as the second argument. This means eOuter can use lagshift, for instance, as FUN.

...

Additional parameters for FUN.

Details

outer has limitations; it only works with functions which can take vector inputs for both the first and second arguments, such as "^". As a result, many functions cannot be used for FUN. The function eOuter gets around this limitation by additionally allowing functions which accept a vector for the first argument, but only scalars for the second argument. It can be used everywhere that outer can be used, but also when FUN is limited in this way.

Value

A matrix Z of size length(x) X length(y) containing Z[,i] with values FUN(x,y[i],...).

See Also

outer and ePow

Examples

1
2
3
4
5
6
7
# This implements a function similar to ePow
# FIXME: change ePow to use eOuter!!!
eOuter(1:6,0:2,FUN = `^`)
# Other functions of columns
eOuter(1:10,0:3,FUN = lagshift,lagMax=3,pad=NA)
# FIXME: Make function to allow polynomials to be used:
# eOuter(1:10,1:3,FUN = glaguerre.polynomials, alpha=0.5)

expandFunctions documentation built on May 2, 2019, 9:15 a.m.