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)
Run the code above in your browser using DataLab