The goal of comunista
is to clean up accents from municipality names
of Chile and gets them in proper format to make joining datasets by
municipality easier.
You can install the development version of comunista from GitHub with:
# install.packages("devtools")
devtools::install_github("lhersko/comunista")
If you use pacman, you can install it using:
# install.packages("pacman")
# library(pacman)
p_load_gh("lhersko/comunista")
To use the clean_comunas() function first specify your data frame name and then the variable that contains municipality names in quotations. For example:
library(comunista)
df <- data.frame(comunas=c("ñuñoa", "Peñalolén", "PEñaflor", "Las condes"))
clean_comunas(df, "comunas")
#> comunas
#> 1 Nunoa
#> 2 Penalolen
#> 3 Penaflor
#> 4 Las Condes
To use the code_comunas() function first specify your data frame name and then the variable that contains municipality names in quotations. For example:
library(comunista)
df <- data.frame(comunas=c("ñuñoa", "Peñalolén", "PEñaflor", "Las condes"))
df_clean <- clean_comunas(df, "comunas")
code_comunas(df_clean, "comunas")
#> comunas cod_comuna
#> 1 Las Condes 13114
#> 2 Nunoa 13120
#> 3 Penaflor 13605
#> 4 Penalolen 13122
It is strongly suggested that you run clean_comunas() on your data before running code_comunas().
To use the code_regiones() function first specify your data frame name and then the variable that contains municipality names in quotations. For example:
library(comunista)
df <- data.frame(comunas=c("ñuñoa", "Peñalolén", "PEñaflor", "Las condes"))
clean_df <- clean_comunas(df, "comunas")
code_regiones(clean_df, "comunas")
#> comunas nom_region_2000 nom_region_2008
#> 1 Las Condes Metropolitana de Santiago Metropolitana de Santiago
#> 2 Nunoa Metropolitana de Santiago Metropolitana de Santiago
#> 3 Penaflor Metropolitana de Santiago Metropolitana de Santiago
#> 4 Penalolen Metropolitana de Santiago Metropolitana de Santiago
#> nom_region_2018 cod_region_2000 cod_region_2008 cod_region_2018
#> 1 Metropolitana de Santiago 13 13 13
#> 2 Metropolitana de Santiago 13 13 13
#> 3 Metropolitana de Santiago 13 13 13
#> 4 Metropolitana de Santiago 13 13 13
It is strongly suggested that you run clean_comunas() on your data before running code_regiones().