Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

outer: Outer Product of Arrays

outerR Documentation

Outer Product of Arrays

Description

The outer product of the arraysX andY is the arrayA with dimensionc(dim(X), dim(Y)) where elementA[c(arrayindex.x, arrayindex.y)] = FUN(X[arrayindex.x], Y[arrayindex.y], ...).

Usage

outer(X, Y, FUN = "*", ...)X %o% Y

Arguments

X, Y

First and second arguments for functionFUN.Typically a vector or array.

FUN

a function to use on the outer products, foundviamatch.fun (except for the special case"*").

...

optional arguments to be passed toFUN.

Details

X andY must be suitable arguments forFUN. Eachwill be extended byrep to length the products of thelengths ofX andY beforeFUN is called.

FUN is called with these two extended vectors as arguments(plus any arguments in...). It must be a vectorizedfunction (or the name of one) expecting at least two arguments andreturning a value with the same length as the first (and the second).

Where they exist, the [dim]names ofX andY will becopied to the answer, and a dimension assigned which is theconcatenation of the dimensions ofX andY (or lengthsif dimensions do not exist).

FUN = "*" is handled as a special caseviaas.vector(X) %*% t(as.vector(Y)), and is intended only fornumeric vectors and arrays.

%o% is binary operator providing a wrapper forouter(x, y, "*").

Author(s)

Jonathan Rougier

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.

See Also

%*% for usual (inner) matrix vectormultiplication;kronecker which is based onouter;Vectorize for vectorizing a non-vectorized function.

Examples

x <- 1:9; names(x) <- x# Multiplication & Power Tablesx %o% xy <- 2:8; names(y) <- paste(y,":", sep = "")outer(y, x, "^")outer(month.abb, 1999:2003, FUN = "paste")## three way multiplication table:x %o% x %o% y[1:3]

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2026 Movatter.jp