conapomx data package

[This article was first published on En El Margen - R-English, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I have created a new R data package to help users obtain national population statistics of Mexico.

The conapomx package contains the mxpopulation data set, which is a tidy data.frame containing population estimates from the CONAPO (National Population Commission) official agency. The estimates are divided by age groups, gender, municipality and year.

To install, just call CRAN (or github if you are reading this before it is accepted).

install.packages("conapomx") 
# or... 
library(devtools)
install_github("eflores89/conapomx")

# explore the dataset
head(mxpopulation)
ystid_stmunid_mungeoidgenderagepopulation
2010Aguascalientes1Aguascalientes1100100-14124263.71
2010Aguascalientes1Aguascalientes11001015-29106695.14
2010Aguascalientes1Aguascalientes11001030-4481088.65
2010Aguascalientes1Aguascalientes11001045-6460379.29
2010Aguascalientes1Aguascalientes11001065+17679.26
2010Aguascalientes1Aguascalientes1100110-14119535.77

Here is the data for 2018, just out of curiosity:

library(dplyr)

mxpopulation %>% 
  filter(y == "2018") %>%
  group_by(st) %>% 
  summarize("Population" = sum(population))
stPopulation
Aguascalientes1337792.5
Baja California3633772.2
Baja California Sur832827.2
Campeche948459.3
Chiapas5445232.7
Chihuahua3816865.4
Coahuila3063662.5
Colima759686.5
Distrito Federal8788140.6
Durango1815965.6
Guanajuato5952086.5
Guerrero3625040.0
Hidalgo2980532.2
Jalisco8197483.1
Mexico17604619.1
Michoacan4687210.5
Morelos1987595.8
Nayarit1290518.8
Nuevo Leon5300618.6
Oaxaca4084674.0
Puebla6371380.8
Queretaro2091823.2
Quintana Roo1709478.7
San Luis Potosi2824976.0
Sinaloa3059321.7
Sonora3050472.7
Tabasco2454294.5
Tamaulipas3661161.7
Tlaxcala1330142.6
Veracruz8220321.9
Yucatan2199617.6
Zacatecas1612014.2

Hopefully this helps to avoid the notoriously bad datos.gob webpage! Happy data wrangling!

To leave a comment for the author, please follow the link and comment on their blog: En El Margen - R-English.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)