matrix-gridVector: Grid vector coordinates

gridVectorR Documentation

Grid vector coordinates

Description

Creates rectangular grid coordinates from two vectors.

Usage

gridVector(x, y = NULL)

Arguments

x,y

numeric vectors

Details

The grid is obtained by pairing each element of y with all elements of x. The X and Y coordinates of the points are stored in separate vectors. This is convenient, for example, for plotting. It can be useful also for brute force optimisation or simulation.

If y is NULL, the default, then y = x.

Value

a list with two components, X and Y, giving the coordinates which span the bivariate grid.

See Also

expand.grid

Examples

## a small grid vector with row and col transformations
gridVector(0:2)
data.frame(gridVector(0:2))
do.call("rbind", gridVector(0:2))

gridVector(0:2, 0:3)

## grid over a unit square
gridVector((0:10)/10) # equivalently: gridVector((0:10)/10, (0:10)/10)

fBasics documentation built on Nov. 3, 2023, 5:10 p.m.