as_gridref: Convert a string to a gridref object

View source: R/gridref.R

as_gridrefR Documentation

Convert a string to a gridref object

Description

Converts a valid grid reference character string to a gridref object.

Usage

as_gridref(grid_reference = character())

Arguments

grid_reference

A Great British or Irish grid reference character string.

Details

Checks that the character string is a valid grid reference before converting to a gridref class. Returns an error if the grid reference is invalid.

Value

A grid reference character string with an added gridref class.

See Also

Constructor function for gridref class as described in S3 chapter of Advanced R second additon by Hadley Wickham.

Examples

 suppressPackageStartupMessages({
   suppressWarnings({
     library(dplyr)
     library(janitor)
   })
 })

 grid_references <- nbn_demonstration_dataset %>%
   clean_names() %>%
   slice_tail(n = 15) %>%
   select(grid_reference) %>%
   mutate(grid_reference = as_gridref(grid_reference))


# check grid_reference class
suppressPackageStartupMessages({
  suppressWarnings({
    library(purrr)
  })
})

grid_references %>%
 map_chr(., class)

gcfrench/store documentation built on May 17, 2024, 5:52 p.m.