is_region_code: Check if string is region code

View source: R/test_region_classifications.R

is_region_codeR Documentation

Check if string is region code

Description

Given a vector of potential region codes, returns a vector of logicals indicating which elements are region codes. Allows prefixed and non-prefixed region codes.

Usage

is_region_code(x, region_level = NULL, year = NULL, offline = TRUE)

Arguments

x

vector, a potential region code.

region_level

character, optional region level of the input region codes. Possible region_levels are statficlassifications:::prefix_name_key$name.

year

double, year of region classification searched.

offline

logical, whether works offline with package data. Defaults to TRUE.

Details

Uses is_region_code_with_prefix() and is_region_code_without_prefix(). These functions are required as such also elsewhere.

Region variable detection functions use the testing functions here.

Value

logical

Examples


  is_region_code(c("KU005", "005"))
  is_region_code_with_prefix(c("KU005", "005"))
  is_region_code_without_prefix(c("KU005", "005"))
  is_region_code_with_prefix(c("KU005", "005"), region_level = "maakunta")
  is_region_code_without_prefix(c("KU005", "005"), region_level = "maakunta")


pttry/statficlassifications documentation built on Jan. 17, 2024, 4:36 p.m.