# NOT RUN {
# Load some pivoted data
(x <- purpose$`NNW WNW`)
# Make a tidy representation
cells <- tidy_table(x)
cells <- cells[!is.na(cells$chr), ] # Introduce 'holes' in the data
# Select an L-shape with gaps
bag <- dplyr::filter(cells, row %in% 3:4, col %in% 1:2)
# Offset, notice the L has been squared-off (padded)
offset_N(bag, cells, 1)
# Select a particular cell
cell <- cells[which(cells$row == 3 & cells$col == 3), ]
# Offset the selection downwards, stopping before the NA.
offset_S(cell, cells, boundary = ~ is.na(chr))
# Offset the selection right, up to and including the fifth column.
offset_E(cell, cells, boundary = ~ col == 5, include = TRUE)
# Offset the selection beyond the existing cells
offset_E(cell, cells, 15)
# This doesn't work inside formulas, because it would mean testing the
# boundary formula on every possible cell in the given direction
# }
# NOT RUN {
offset_E(cell, cells, boundary = ~ col == 15)
# }
# NOT RUN {
cell <- cells[which(cells$row == 7 & cells$col %in% 1:2), ]
offset_N(cell, cells, boundary = ~ !is.na(chr), edge = TRUE)
# }
Run the code above in your browser using DataLab