mouter: A generalization of base::outer()

Description Usage Arguments Value Examples

Description

Given a list of vector or arrays applie outer consecutively.

Usage

1
mouter(..., retval = c("tibble", "df", "array"), responseName = "n")

Arguments

...

vectors or matrices

retval

character, whether to return a data frame ("df") or array ("array")

responseName

character scalar, when returning a data frame this will be the name of the variable containing cell values

Given the list of vectors and/or arrays outer is used to combine the elements one-by-one (using Reduce).

Value

Depending on the value of retval, an array or a data frame with the outer product of elements supplied through ....

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# As an array
a <- mouter(
  A = c(a=1, b=2) / 3,
  M = matrix(1:4 / 10, 2, 2, dimnames=list(D=letters[5:6], E=letters[7:8])),
  B = c(c=2, d=3) / 5,
  retval="a"
)

str(a)

# Data frame
mouter(
  A = c(a=1, b=2) / 3,
  M = matrix(1:4 / 10, 2, 2, dimnames=list(D=letters[5:6], E=letters[7:8])),
  B = c(c=2, d=3) / 5,
  retval="df"
)

mbojan/mouter documentation built on May 22, 2019, 12:55 p.m.