<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/conapomx-data-package-2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://enelmargen.org/datascience/conapo-package/"> En El Margen - R-English</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I have created a new data package for R to help users obtain national population statistics of Mexico.</p>
<p>The <strong>conapomx</strong> package contains the <em>mxpopulation</em> 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.</p>
<p>To install, just call CRAN (or github if you are reading this before it is accepted).</p>
<figure>
<pre><code data-lang="r">install.packages(&quot;conapomx&quot;) 
# or... 
library(devtools)
install_github(&quot;eflores89/conapomx&quot;)

# explore the dataset
head(mxpopulation)</code></pre>
</figure>
<table>
<thead>
<tr>
<th>y</th>
<th>st</th>
<th>id_st</th>
<th>mun</th>
<th>id_mun</th>
<th>geoid</th>
<th>gender</th>
<th>age</th>
<th>population</th>
</tr>
</thead>
<tbody>
<tr>
<td>2010</td>
<td>Aguascalientes</td>
<td>1</td>
<td>Aguascalientes</td>
<td>1</td>
<td>1001</td>
<td>0</td>
<td>0-14</td>
<td>124263.71</td>
</tr>
<tr>
<td>2010</td>
<td>Aguascalientes</td>
<td>1</td>
<td>Aguascalientes</td>
<td>1</td>
<td>1001</td>
<td>0</td>
<td>15-29</td>
<td>106695.14</td>
</tr>
<tr>
<td>2010</td>
<td>Aguascalientes</td>
<td>1</td>
<td>Aguascalientes</td>
<td>1</td>
<td>1001</td>
<td>0</td>
<td>30-44</td>
<td>81088.65</td>
</tr>
<tr>
<td>2010</td>
<td>Aguascalientes</td>
<td>1</td>
<td>Aguascalientes</td>
<td>1</td>
<td>1001</td>
<td>0</td>
<td>45-64</td>
<td>60379.29</td>
</tr>
<tr>
<td>2010</td>
<td>Aguascalientes</td>
<td>1</td>
<td>Aguascalientes</td>
<td>1</td>
<td>1001</td>
<td>0</td>
<td>65+</td>
<td>17679.26</td>
</tr>
<tr>
<td>2010</td>
<td>Aguascalientes</td>
<td>1</td>
<td>Aguascalientes</td>
<td>1</td>
<td>1001</td>
<td>1</td>
<td>0-14</td>
<td>119535.77</td>
</tr>
</tbody>
</table>
<p>Here is the data for 2018, just out of curiosity:</p>
<figure>
<pre><code data-lang="r">library(dplyr)

mxpopulation %>% 
  filter(y == &quot;2018&quot;) %>%
  group_by(st) %>% 
  summarize(&quot;Population&quot; = sum(population))</code></pre>
</figure>
<table>
<thead>
<tr>
<th>st</th>
<th>Population</th>
</tr>
</thead>
<tbody>
<tr>
<td>Aguascalientes</td>
<td>1337792.5</td>
</tr>
<tr>
<td>Baja California</td>
<td>3633772.2</td>
</tr>
<tr>
<td>Baja California Sur</td>
<td>832827.2</td>
</tr>
<tr>
<td>Campeche</td>
<td>948459.3</td>
</tr>
<tr>
<td>Chiapas</td>
<td>5445232.7</td>
</tr>
<tr>
<td>Chihuahua</td>
<td>3816865.4</td>
</tr>
<tr>
<td>Coahuila</td>
<td>3063662.5</td>
</tr>
<tr>
<td>Colima</td>
<td>759686.5</td>
</tr>
<tr>
<td>Distrito Federal</td>
<td>8788140.6</td>
</tr>
<tr>
<td>Durango</td>
<td>1815965.6</td>
</tr>
<tr>
<td>Guanajuato</td>
<td>5952086.5</td>
</tr>
<tr>
<td>Guerrero</td>
<td>3625040.0</td>
</tr>
<tr>
<td>Hidalgo</td>
<td>2980532.2</td>
</tr>
<tr>
<td>Jalisco</td>
<td>8197483.1</td>
</tr>
<tr>
<td>Mexico</td>
<td>17604619.1</td>
</tr>
<tr>
<td>Michoacan</td>
<td>4687210.5</td>
</tr>
<tr>
<td>Morelos</td>
<td>1987595.8</td>
</tr>
<tr>
<td>Nayarit</td>
<td>1290518.8</td>
</tr>
<tr>
<td>Nuevo Leon</td>
<td>5300618.6</td>
</tr>
<tr>
<td>Oaxaca</td>
<td>4084674.0</td>
</tr>
<tr>
<td>Puebla</td>
<td>6371380.8</td>
</tr>
<tr>
<td>Queretaro</td>
<td>2091823.2</td>
</tr>
<tr>
<td>Quintana Roo</td>
<td>1709478.7</td>
</tr>
<tr>
<td>San Luis Potosi</td>
<td>2824976.0</td>
</tr>
<tr>
<td>Sinaloa</td>
<td>3059321.7</td>
</tr>
<tr>
<td>Sonora</td>
<td>3050472.7</td>
</tr>
<tr>
<td>Tabasco</td>
<td>2454294.5</td>
</tr>
<tr>
<td>Tamaulipas</td>
<td>3661161.7</td>
</tr>
<tr>
<td>Tlaxcala</td>
<td>1330142.6</td>
</tr>
<tr>
<td>Veracruz</td>
<td>8220321.9</td>
</tr>
<tr>
<td>Yucatan</td>
<td>2199617.6</td>
</tr>
<tr>
<td>Zacatecas</td>
<td>1612014.2</td>
</tr>
</tbody>
</table>
<p>Hopefully this helps to avoid the notoriously bad <em>datos.gob</em> webpage! Happy data wrangling!</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://enelmargen.org/datascience/conapo-package/"> En El Margen - R-English</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/_ukTrlJ32jU" height="1"></a></div>