The data.frame you provide to the plotting functions
must have a region column and a value column.
The region entries must be INEGI codes for states (e.g.,
“01”, “02”) or municipios (e.g., “01001”, “01002”). These codes can be
strings (with or without a leading zero) or numeric. The package
provides the str_mxstate and str_mxmunicipio
functions to easily format these codes to the INEGI specification. The
package also includes example data.frame objects, such as
df_mxstate_2025 and df_mxmunicipio_2025, which
contain demographic variables from the 2025 Encuesta Intercensal
|
region
|
state_name
|
state_name_official
|
state_abbr
|
state_abbr_official
|
year
|
pop
|
pop_male
|
pop_female
|
afromexican
|
indigenous
|
|
01
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
2025
|
1534416
|
736415
|
798001
|
9820
|
67054
|
|
02
|
Baja California
|
Baja California
|
BC
|
BC
|
2025
|
3978593
|
1970328
|
2008265
|
56496
|
366031
|
|
03
|
Baja California Sur
|
Baja California Sur
|
BCS
|
BCS
|
2025
|
955465
|
479273
|
476192
|
33919
|
103286
|
|
04
|
Campeche
|
Campeche
|
CAMP
|
Camp.
|
2025
|
967098
|
469392
|
497706
|
20309
|
398638
|
|
05
|
Coahuila
|
Coahuila de Zaragoza
|
COAH
|
Coah.
|
2025
|
3404559
|
1677826
|
1726733
|
44259
|
118138
|
|
06
|
Colima
|
Colima
|
COL
|
Col.
|
2025
|
758987
|
370780
|
388207
|
11005
|
102995
|
data("df_mxmunicipio_2025")
htmlTable(head(df_mxmunicipio_2025), rnames = FALSE, col.rgroup = c("none", "#F7F7F7"))
|
state_code
|
municipio_code
|
region
|
state_name
|
state_name_official
|
state_abbr
|
state_abbr_official
|
municipio_name
|
year
|
pop
|
pop_male
|
pop_female
|
afromexican
|
indigenous
|
metro_area
|
long
|
lat
|
|
1
|
1
|
01001
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Aguascalientes
|
2025
|
1025505
|
491035
|
534470
|
6666
|
46455
|
Aguascalientes
|
-102.296046
|
21.879822
|
|
1
|
2
|
01002
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Asientos
|
2025
|
53631
|
25691
|
27940
|
499
|
2113
|
|
-102.089275
|
22.238317
|
|
1
|
3
|
01003
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Calvillo
|
2025
|
55794
|
26894
|
28900
|
385
|
1612
|
|
-102.71875
|
21.846907
|
|
1
|
4
|
01004
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Cosío
|
2025
|
17504
|
8276
|
9228
|
81
|
805
|
|
-102.300044
|
22.366409
|
|
1
|
5
|
01005
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Jesús María
|
2025
|
147302
|
71905
|
75397
|
1105
|
7439
|
Aguascalientes
|
-102.343416
|
21.961273
|
|
1
|
6
|
01006
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Pabellón de Arteaga
|
2025
|
49372
|
23697
|
25675
|
267
|
2222
|
|
-102.276541
|
22.149201
|
2020 Census
data("df_mxstate_2020")
htmlTable(head(df_mxstate_2020), rnames = FALSE, col.rgroup = c("none", "#F7F7F7"))
|
region
|
state_name
|
state_name_official
|
state_abbr
|
state_abbr_official
|
year
|
pop
|
pop_male
|
pop_female
|
afromexican
|
indigenous_language
|
|
01
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
2020
|
1425607
|
696683
|
728924
|
22425
|
2539
|
|
02
|
Baja California
|
Baja California
|
BC
|
BC
|
2020
|
3769020
|
1900589
|
1868431
|
64362
|
49130
|
|
03
|
Baja California Sur
|
Baja California Sur
|
BCS
|
BCS
|
2020
|
798447
|
405879
|
392568
|
26330
|
13581
|
|
04
|
Campeche
|
Campeche
|
CAMP
|
Camp.
|
2020
|
928363
|
456939
|
471424
|
19319
|
91801
|
|
05
|
Coahuila
|
Coahuila de Zaragoza
|
COAH
|
Coah.
|
2020
|
3146771
|
1563669
|
1583102
|
45976
|
5527
|
|
06
|
Colima
|
Colima
|
COL
|
Col.
|
2020
|
731391
|
360622
|
370769
|
13574
|
5210
|
data("df_mxmunicipio_2020")
htmlTable(head(df_mxmunicipio_2020), rnames = FALSE, col.rgroup = c("none", "#F7F7F7"))
|
state_code
|
municipio_code
|
region
|
state_name
|
state_name_official
|
state_abbr
|
state_abbr_official
|
municipio_name
|
year
|
pop
|
pop_male
|
pop_female
|
afromexican
|
indigenous_language
|
metro_area
|
long
|
lat
|
|
01
|
001
|
01001
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Aguascalientes
|
2020
|
948990
|
462073
|
486917
|
15170
|
1839
|
Aguascalientes
|
-102.296047
|
21.879823
|
|
01
|
002
|
01002
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Asientos
|
2020
|
51536
|
25261
|
26275
|
225
|
22
|
|
-102.089275
|
22.238317
|
|
01
|
003
|
01003
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Calvillo
|
2020
|
58250
|
28563
|
29687
|
266
|
76
|
|
-102.718751
|
21.846907
|
|
01
|
004
|
01004
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Cosío
|
2020
|
17000
|
8292
|
8708
|
2155
|
7
|
|
-102.300044
|
22.366409
|
|
01
|
005
|
01005
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Jesús María
|
2020
|
129929
|
64219
|
65710
|
2543
|
158
|
Aguascalientes
|
-102.343416
|
21.961273
|
|
01
|
006
|
01006
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Pabellón de Arteaga
|
2020
|
47646
|
23377
|
24269
|
482
|
52
|
|
-102.276542
|
22.149202
|
2015 Conteo Intercensal
Additional data.frame objects are available with data
from other censuses and conteos intercensales.
data("df_mxstate_2015")
htmlTable(head(df_mxstate_2015), rnames = FALSE, col.rgroup = c("none", "#F7F7F7"))
|
region
|
state_name
|
state_name_official
|
state_abbr
|
state_abbr_official
|
year
|
pop
|
pop_male
|
pop_female
|
afromexican
|
part_afromexican
|
indigenous
|
part_indigenous
|
|
01
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
2015
|
1312544
|
640091
|
672453
|
653
|
4559
|
153395
|
18716
|
|
02
|
Baja California
|
Baja California
|
BC
|
BC
|
2015
|
3315766
|
1650341
|
1665425
|
7445
|
10432
|
283055
|
38391
|
|
03
|
Baja California Sur
|
Baja California Sur
|
BCS
|
BCS
|
2015
|
712029
|
359137
|
352892
|
11032
|
5132
|
103034
|
11728
|
|
04
|
Campeche
|
Campeche
|
CAMP
|
Camp.
|
2015
|
899931
|
441276
|
458655
|
3554
|
6833
|
400811
|
13140
|
|
05
|
Coahuila
|
Coahuila de Zaragoza
|
COAH
|
Coah.
|
2015
|
2954915
|
1462612
|
1492303
|
2761
|
8137
|
204890
|
28588
|
|
06
|
Colima
|
Colima
|
COL
|
Col.
|
2015
|
711235
|
350791
|
360444
|
762
|
3314
|
145297
|
12373
|
data("df_mxmunicipio_2015")
htmlTable(head(df_mxmunicipio_2015), rnames = FALSE, col.rgroup = c("none", "#F7F7F7"))
|
state_code
|
municipio_code
|
region
|
state_name
|
state_name_official
|
state_abbr
|
state_abbr_official
|
municipio_name
|
year
|
pop
|
pop_male
|
pop_female
|
afromexican
|
part_afromexican
|
indigenous
|
part_indigenous
|
metro_area
|
long
|
lat
|
|
01
|
001
|
01001
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Aguascalientes
|
2015
|
877190
|
425731
|
451459
|
532
|
2791
|
104125
|
14209
|
Aguascalientes
|
-102.296047
|
21.879823
|
|
01
|
002
|
01002
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Asientos
|
2015
|
46464
|
22745
|
23719
|
3
|
130
|
1691
|
92
|
|
-102.089275
|
22.238317
|
|
01
|
003
|
01003
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Calvillo
|
2015
|
56048
|
27298
|
28750
|
10
|
167
|
7358
|
2223
|
|
-102.718751
|
21.846907
|
|
01
|
004
|
01004
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Cosío
|
2015
|
15577
|
7552
|
8025
|
0
|
67
|
2213
|
191
|
|
-102.300044
|
22.366409
|
|
01
|
005
|
01005
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Jesús María
|
2015
|
120405
|
60135
|
60270
|
32
|
219
|
8679
|
649
|
Aguascalientes
|
-102.343416
|
21.961273
|
|
01
|
006
|
01006
|
Aguascalientes
|
Aguascalientes
|
AGS
|
Ags.
|
Pabellón de Arteaga
|
2015
|
46473
|
22490
|
23983
|
3
|
74
|
6232
|
251
|
|
-102.276542
|
22.149202
|
Older Censuses
data("df_mxstate_1990_2010")
htmlTable(head(df_mxstate_1990_2010), rnames = FALSE, col.rgroup = c("none", "#F7F7F7"))
|
region
|
state_name_official
|
year
|
sex
|
pop
|
|
01
|
Aguascalientes
|
1990
|
Total
|
719659
|
|
01
|
Aguascalientes
|
1995
|
Total
|
862720
|
|
01
|
Aguascalientes
|
2000
|
Total
|
944285
|
|
01
|
Aguascalientes
|
2005
|
Total
|
1065416
|
|
01
|
Aguascalientes
|
2010
|
Total
|
1184996
|
|
01
|
Aguascalientes
|
1990
|
Male
|
350218
|
data("df_mxmunicipio_1990_2010")
htmlTable(head(df_mxmunicipio_1990_2010), rnames = FALSE, col.rgroup = c("none", "#F7F7F7"))
|
region
|
municipio_name
|
year
|
sex
|
pop
|
|
01001
|
Aguascalientes
|
1990
|
Total
|
506274
|
|
01001
|
Aguascalientes
|
1995
|
Total
|
582827
|
|
01001
|
Aguascalientes
|
2000
|
Total
|
643419
|
|
01001
|
Aguascalientes
|
2005
|
Total
|
723043
|
|
01001
|
Aguascalientes
|
2010
|
Total
|
797010
|
|
01001
|
Aguascalientes
|
1990
|
Male
|
245197
|
The package includes two versions of state names and abbreviations.
This is because common usage often differs from official names. For
example, most people use “Veracruz” instead of the full official name,
“Veracruz de Ignacio de la Llave.” Similarly, the official abbreviation
for Chiapas, “Chis.”, can be awkward in some Spanish speaking
countries.
String conversion
INEGI municipality identifiers are fixed-width, five-character
geographic codes composed of a two-digit state code (Entidad Federativa)
followed by a three-digit municipality code (Municipio). The
municipality component is zero-padded to a width of three digits,
meaning that valid identifiers may contain one or more leading zeros
(e.g., 01001, 02003, 09002). Leading zeros are semantically significant
and form part of the official identifier; they do not represent
insignificant numeric padding. Consequently, INEGI codes should be
stored and processed as character strings rather than numeric values.
Converting these identifiers to numeric types can strip leading zeros,
altering the code and potentially causing referential integrity issues,
failed joins, duplicate records, or mismatches
## [1] "32" "05"
## [1] "32009" "05018"
## [1] "32001" "05009"