long_grid {ambient}R Documentation

Create a long format grid

Description

This function creates a 1-4 dimensional grid in long format, with the cell positions encoded in the x, y, z, and t columns. A long_cell object is the base class for the tidy interface to ambient, and allows a very flexible approach to pattern generation at the expense of slightly lower performance than the ⁠noise_*⁠ functions that maps directly to the underlying C++ code.

Usage

long_grid(x, y = NULL, z = NULL, t = NULL)

grid_cell(grid, dim, ...)

## S3 method for class 'long_grid'
as.array(x, value, ...)

## S3 method for class 'long_grid'
as.matrix(x, value, ...)

## S3 method for class 'long_grid'
as.raster(x, value, ...)

slice_at(grid, ...)

Arguments

x, y, z, t

For long_grid() vectors of grid cell positions for each dimension. The final dimensionality of the object is determined by how many arguments are given. For slice_at() an integer defining the index at the given dimension to extract.

grid

A long_grid object

dim

The dimension to get the cell index at, either as an integer or string.

...

Arguments passed on to methods (ignored)

value

The unquoted value to use for filling out the array/matrix

Examples

grid <- long_grid(1:10, seq(0, 1, length = 6), c(3, 6))

# Get which row each cell belongs to
grid_cell(grid, 2) # equivalent to grid_cell(grid, 'y')

# Convert the long_grid to an array and fill with the x position
as.array(grid, x)

# Extract the first column
slice_at(grid, x = 1)

# Convert the first column to a matrix filled with y position
as.matrix(slice_at(grid, x = 1), y)


[Package ambient version 1.0.2 Index]