View source: R/gen_admin_div.R
gen_admin_div | R Documentation |
Function 'gen_admin_div' returns the natural, geographical, or administrative division of Peru that includes the region, province or district provided to the function.
gen_admin_div(x, method = "Traditional")
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) |
Converts characters where it detects regions of Peru with the resulting divisions specified.
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")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.