Learn R Programming

unpivotr (version 0.3.1)

anchor: Filter for a cell from which to select others

Description

anchor protects you from selecting initial cells that do not exist. This is useful when choosing inital cells from which to search for others, using offset and extend. If the chosen cells do not exist, then cells are generated at the given rows and columns, with NAs in every column other than 'row' and 'col'.

Usage

anchor(cells, rows, cols, cross = TRUE)

Arguments

cells

Data frame, the cells among which the anchor will be sought

rows

Numeric, the rows of the intended cells

cols

Numeric, the columns of the intended cell

cross

Logical, whether to 'cross' the given rows and columns to generate all combinations. Unless this is TRUE, rows and cols must be the same length. TRUE by default.

Examples

Run this code
# NOT RUN {
cells <- tidy_table(purpose$`NNW WNW`)
# }
# NOT RUN {
  anchor(cells, 0, 1)
  anchor(cells, 1, 1:2)
# }
# NOT RUN {
anchor(cells, 1, 1)
anchor(cells, 1, 1:2, cross = TRUE)
anchor(cells, 100, 1)
# }

Run the code above in your browser using DataLab