in_csquares {csquares}R Documentation

Match c-squares against other c-squares (with wildcards)

Description

Checks if csquares codes in table matches values in x. Wildcards are allowed in table for this comparison. Check out vignette("wildcards") for more details.

Usage

in_csquares(x, table, strict = FALSE, mode = "any", ...)

Arguments

x

An object of class 'csquares' that will be checked for matching values in table

table

A character string representing a csquares code. The code can contain wildcards (asterisk * and percentage ⁠%⁠ characters, both having identical meaning). Any symbol in x will result in a positive match against the wildcard. table can also be of class csquares, but these objects cannot contain wildcards.

strict

When set to FALSE, a match is positive when the start of x, matches against values in table, even when x has a higher resolution. When set to TRUE, a match is only positive when the resolution of x and table is identical.

mode

Two modes are allowed: "all" and "any". When an element of x consists of multiple raster cells, it the mode will determine whether a match is positive or not. In case of "all", all raster cells in the element of x need to match with the cells in table, for a positive match. In case of "any", any match will do.

...

Ignored

Value

Returns a vector of logical values with the same number of elements or rows as x

Author(s)

Pepijn de Vries

Examples

library(dplyr)

in_csquares(orca$csquares, c("3400:2", "5515:3"))
in_csquares(orca$csquares, "3400:2|5515:3")

## Percentage symbols are interpreted the same as asterisk symbols
## both are wild cards
in_csquares(orca$csquares, "1%%%:%") |>
  table()

## Same as above
in_csquares(orca$csquares, "1***:*") |>
  table()
 
## Also same as above
in_csquares(orca$csquares, "1***", strict = FALSE) |>
  table()

## Strict interpretation results in no matches
in_csquares(orca$csquares, "1***", strict = TRUE) |>
  table()

## Filter orca data to North Eastern quadrant (1***:*) only:
orca |>
  filter(
    in_csquares(csquares, "1***:*")
  ) |>
  nrow()


[Package csquares version 0.0.7 Index]