outerList: Outer Product of Lists

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/listOperations.R

Description

The outer product of the lists X and Y is the matrix M with dimension c(length(X), length(Y)) where element M[i, j] = FUN(X[[i]], Y[[j]]).

Usage

1
outerList(X, Y, FUN, ...)

Arguments

X

a list.

Y

a list.

FUN

a function to use on the outer product, taking elements of X and Y as arguments.

...

additional arguments passed to FUN.

Details

X and Y must be suitable arguments for FUN. Each will be extended by rep to length the products of the lengths of X and Y before FUN is called.

FUN is the applied to these two extended vectors by mapply.

When they exist, the names of X and Y will be used as rownames and colnames.

Value

A matrix with dimension c(length(X), length(Y)) where element M[i, j] = FUN(X[[i]], Y[[j]]).

Author(s)

Antoine Filipovic Pierucci

See Also

outer, mapply.

Examples

1
2
3
4
5
6
a <- list(a = 1:3, b = 4:7, c = 8:9)
b <- list(x = 4:8, y = 0:1)
f <- function(x, y)
    any(match(x, y, nomatch = 0L) > 0L)

outerList(a, b, f)

Example output


rmngb documentation built on May 29, 2017, 9:22 p.m.

Related to outerList in rmngb...