65_outer_generalizations_1: Outer Generalizations 1

Description Usage Arguments Value See Also Examples

Description

Constructors for S4 objects, containing a matrix (gv) and coordinates (x and y), or (xb and yb).

Essentially, the gv slot is equivalent to the matrix returned by base::outer, over the x and y values.
DGrid is for integer inputs and CGrid is for numeric inputs.

The StepGrid version is for step functions, where xb and yb represent breakpoints.
The gv values are evaluated using the midpoints.

The xgrid.hdim function and related functions, can be used to produce arrays in higher dimensions.

Usage

1
2
3
4
5
6
7
DGrid (x = 1:nrow (gv), y = 1:ncol (gv), gv)
CGrid (x = 1:nrow (gv), y = 1:ncol (gv), gv)
StepGrid (xb = 0:nrow (gv) + 0.5, yb = 0:ncol (gv) + 0.5, gv)

dgrid (sf=`*`, xlim, ylim=xlim, ..., cf, iterate=FALSE, x, y)
cgrid (sf=`*`, xlim, ylim=xlim, ..., n=8, cf, iterate=FALSE, x, y)
stepgrid (sf=`*`, xlim, ylim=xlim, ..., n=8, cf, iterate=FALSE, xb, yb)

Arguments

sf

A suitable function.
It's first argument should be a matrix/list/etc, if cf provided, otherwise it should have leading arguments, for x and y.

xlim, ylim

Length-two integer (for DGrid) or numeric (for CGrid/SGrid) vectors.
These give the limits for the sequences.

n

Integer vector of length one or two, the number or rows and columns.
For CGrid, this is also the length of the x and y sequences.
For StepGrid, xb and yb will be one longer.

iterate

Logical, if true, evaluate the function with one bin/point, at a time. Note that this is not done in an efficient way, you'll get a faster result if you vectorize your function.

cf

A function of two vectors, used to combine x and y into a single object.
The sf function is called using the result of the cf function.

x, y

Integer or numeric vectors.

xb, yb

Same as x and y, but one longer, for breakpoints/endpoints.

gv

A matrix of grid values, equivalent to the result of sf.

...

Currently, ignored.

Value

An DGrid, CGrid or SGrid object.

See Also

dgrid.hdim, cgrid.hdim, xgrid.hdim

Examples

1
2
3
4
5
6
7
8
f <- function (v)
    v [,1] + v [,2]

#simple addition problem
dgrid (`+`, c (0, 4), c (1, 5) )

#same, but f operates on matrix
dgrid (f, c (0, 4), c (1, 5), cf=cbind)

vectools documentation built on June 7, 2021, 9:08 a.m.