This R package can be used to easily create maps of Mexico at both the state and municipio levels. It is based on the choroplethr package and includes functions to create interactive maps using the leaflet package, map INEGI data using their API with the inegiR package, and format strings so they match the INEGI state and municipio codes. Feel free to ask for help in the discussion forum
For the moment this package is only available from github. For the development version:
mxmaps depends on the sf package which has other dependencies
What the data looks like:
The two basic functions of the package are
mxmunicipio_choropleth. The data.frame that you provide to the plotting functions must have one column named
region with the INEGI codes of the states or municipios and another one named
value with the values to plot. You can specify a title with the
title parameter and the number of buckets for the color scale with the
num_color parameter. If you need a continuous scale you can set the
num_colors parameter equal to 1.
You can also plot Mexican municipios (similar to counties) with a continuous color scale set with num_colors = 1
You can also subset the area to show in the choropleth by using the zoom parameter:
You can use the
show_states parameter to hide or show the state borders when making municipio choropleths.