igr_is_valid()
identifies valid Irish grid references.
Details
Valid Irish grid references consist of a letter (other than I) optionally followed by both an easting and northing. The easting and northing must be of the same length of between 1 and 5 digits. There may be whitespace between the letter, easting and northing.
The tetrad form of Irish grid reference consists of a valid 10 km precision Irish grid reference (one letter, one digit easting and one digit northing) followed by a letter (other than O). This refers to a 2 km square within the 10 km square referenced.
Examples
# A vector of alternating valid and invalid Irish grid references
v <- c("N8090", "D 12 345 88800", "W34", "I30", "W", "A123", "B1234", "", "A12Z", "A12O")
# Check validity of Irish Grid coordinates
igr_is_valid(v)
#> [1] TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
# Check validity of Irish Grid coordinates, disallowing tetrad form
igr_is_valid(v, tetrad = FALSE)
#> [1] TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE