long_grid | R Documentation |
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.
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, ...)
x, y, z, t |
For |
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 |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.