gen_admin_div: Create categories for adiministrative divisions (Peru)

View source: R/gen_admin_div.R

gen_admin_divR Documentation

Create categories for adiministrative divisions (Peru)

Description

Function 'gen_admin_div' returns the natural, geographical, or administrative division of Peru that includes the region, province or district provided to the function.

Usage

gen_admin_div(x, method = "Traditional")

Arguments

x

x is a list/vector with one of the 25 regions/departments names of Peru (first-level administrative subdivisions).

method

defines the type of natural, geographical, or administrative division that should be returned. Possible values are:

- Traditional: Coastal, Andes Mountains, Amazon Jungle, or Lima & Callao - TC: (Lima no incluye Huarua/CaƱete)Administratives Macro Regions of the Constitutional Tribunal - Cardinal: North, South, Amazon Jungle, or Lima & Callao - Trad_Cardinal: Coastal and Andes Mountains are divided into North and South (e.g. South Andes Mountains)

Value

Converts characters where it detects regions of Peru with the resulting divisions specified.

Examples

library(innovar)
library(dplyr)
df_dep <- data.frame(
Region = c("LIMA", "CALLAO", "CAJAMARCA", "AMAZONAS",
           "SAN MARTIN", "HUANUCO", "PASCO", "JUNIN", "CUSCO", "PUNO", "APURIMAC",
            "AYACUCHO", "HUANCAVELICA", "TUMBES", "PIURA", "LAMBAYEQUE",
            "LA LIBERTAD", "ANCASH", "ICA", "AREQUIPA", "TACNA", "MOQUEGUA",
            "LORETO", "UCAYALI", "MADRE DE DIOS"), stringsAsFactors = FALSE
          )

df_dep %>%
  mutate(
    Reg_traditional = gen_admin_div(Region, method = "Traditional"),
    Reg_TC = gen_admin_div(Region, method = "TC"),
    Reg_Cardinal = gen_admin_div(Region, method = "Cardinal"),
    Reg_Trad_Cardinal = gen_admin_div(Region, method = "Trad_Cardinal")
  )


healthinnovation/lis documentation built on June 19, 2024, 6:06 a.m.