I'm trying to create a value map with the following data:
ESTADOS MATRICULAS MATRICULAS1 lon lat
<chr> <dbl> <dbl> <dbl> <dbl>
1 CIUDAD DE MÉXICO 682510 0.167 - 99.1 19.4
2 MÉXICO 454111 0.111 -103 23.6
3 JALISCO 245681 0.0600 -103 20.7
4 PUEBLA 242997 0.0593 - 98.2 19.0
5 VERACRUZ 233867 0.0571 - 96.1 19.2
6 NUEVO LEÓN 203084 0.0496 -100.0 25.6
7 GUANAJUATO 150811 0.0368 -101 21.0
8 SINALOA 140298 0.0343 -107 25.2
9 CHIHUAHUA 127444 0.0311 -106 28.5
10 BAJA CALIFORNIA 119655 0.0292 -115 30.8
Where MATRICULAS
are absolute data and MATRICULAS1
are relative data.
I used the following code:
mex_map <- ggmap(get_map(location = "mexico", maptype = "terrain", zoom = 5), extent = "device")
mex_map + stat_density2d(aes(x = lon, y = lat, fill = ..level.., alpha = ..level..), size = 2, bins = 4, data = df, geom = "polygon")
Generating the following chart:
There are two problems in my understanding.
First the code is creating two captions; according to the data are not being distributed throughout the country, across the various states.
Sincerely.