detect_region_var: Detect region variables in data

View source: R/detect_region_variables.R

detect_region_varR Documentation

Detect region variables in data

Description

Given data, looks for the variable that contains regions. Returns the name of this variable and the corresponding variable name in get_regionkey()

Usage

detect_region_var(data, year = NULL, offline = TRUE)

Arguments

data

data.frame

year,

double, year of the used classification

offline,

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

Value

character(2) Returns the region variable in the original data and the corresponding region variable in the get_regionkey()

Examples


   # Generate random municipal data with random name for the regions
             data <- get_regionkey() |>
                     dplyr::select(kunta_name) |>
                     dplyr::rename_with(~paste(sample(letters, 4), collapse = "")) |>
                     dplyr::mutate(values = rnorm(dplyr::n()))

             detect_region_var(data)


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