Learn R Programming

fBasics (version 4041.97)

gridVector: Grid vector coordinates

Description

Creates rectangular grid coordinates from two vectors.

Usage

gridVector(x, y = NULL)

Value

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

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.

See Also

Examples

Run this code
## 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)

Run the code above in your browser using DataLab