class: center, middle, inverse, title-slide # Herramientas Cuantitativas para el Análisis Político ## Maestría en Ciencia Política [CP44] ### ### Universidad Torcuato Di Tella ### 02/11/2021 --- layout: true <div class="my-footer"><span>Juan Pablo Ruiz Nicolini | @TuQmano | <a href="https://tuqmano.ar/">www.tuqmano.ar</a></span></div> --- class: middle, center, inverse ### Data Viz (III) #### Distintas formas de representar información geográfica --- class: center ## Elegir el gráfico correcto para nuestros datos <img src="clase8_files/figure-html/unnamed-chunk-2-1.png" width="504" /> --- class: center ## Elegir el gráfico correcto para nuestros datos <img src="clase8_files/figure-html/unnamed-chunk-3-1.png" width="50%" /> FUENTE: https://www.data-to-viz.com/caveat/pie.html# --- ## _Único caso útil para un gráfico de tortas_ <img src="figs/piramide.png" width="80%" /> -- ### Tampoco para tanto _A case for pie charts_ - [Fundamentals of Data Visualization, Claus Wilke](https://clauswilke.com/dataviz/visualizing-proportions.html#a-case-for-pie-charts) --- class:inverse ## El problema de los mapas coropléticos ### #Election2020 > **"_Trump loves this 2016 election map because it suggests the majority of the country supports him (...)_"** **([NYT](https://www.nytimes.com/interactive/2020/10/30/opinion/election-results-maps.html))** <img src="figs/nyt.png" width="100%" /> --- ## El problema de los mapas coropléticos ### ARGENTINA 2015 <img src="https://github.com/TuQmano/votemapARG/blob/main/output/001.png?raw=true" width="90%" /> --- ## ARGENTINA 2015 ([repo](https://github.com/TuQmano/votemapARG/)) <img src="https://github.com/TuQmano/votemapARG/raw/main/animacion.gif" width="90%" /> --- class: inverse, center, middle ## Alternativas de visualización _geo_ --- class: center, middle ## Mapa Coroplético <img src="figs/choroplet.png" width="100%" /> --- class: center, middle ## Cartogramas <img src="figs/cartogramas.png" width="100%" /> --- class: center, middle ## _Tilemaps_ <img src="figs/tilemap.png" width="100%" /> --- class: center, middle ## _Faceted tilemaps_ <img src="figs/faceted_tilemap.png" width="100%" /> --- class: center, middle ## Tilegrams <img src="figs/tilegrams.png" width="100%" /> --- class: inverse, middle ## Limitaciones varias * Visualizar una variable / valor por unidad geográfica * Solo hace uso del color para codificación visual (dificultad para calcular diferencias) -- * Sesgo a favor de grandes unidades geográficas --- background-image: url(https://hafen.github.io/geofacet/reference/figures/logo.png) background-position: 95% 5% background-size: 10% class: inverse # Grillas como (si fueran) mapas [
`{geofacet}`](https://ryanhafen.com/blog/geofacet/) <img src="clase8_files/figure-html/unnamed-chunk-13-1.png" width="100%" /> --- class: inverse # Ventajas de `{geofacet}` [
_Voto Popular_ vs _Colegio Electoral_](https://github.com/TuQmano/popular_vote) <img src="https://raw.githubusercontent.com/TuQmano/popular_vote/master/plots/turnount_ts.png" width="70%" /> * se pueden graficar múltiples variables para cada unidad geográfica -- * se pueden aplicar otros esquemas de codificación visual más allá del color -- * cada unidad geográfica tiene asignada la misma proporción espacial --- background-image: url(https://hafen.github.io/geofacet/reference/figures/logo.png) background-position: 95% 5% background-size: 10% # [Grillas colaborativas](https://github.com/hafen/geofacet/issues/102) ### [`geofacet::grid_design()`](https://hafen.github.io/grid-designer/#data=) ```r library(geofacet) grid_preview(argentina_grid2) ``` <img src="clase8_files/figure-html/unnamed-chunk-15-1.png" width="35%" /> (Comunas [_gist_](https://gist.githubusercontent.com/TuQmano/2fb70e11c6500176427bb3b60604b79d/raw/ebe2889269d403dd05ab1db9e6ad624fa02a6e63/comunas.csv)) --- background-image: url(https://github.com/electorArg/geofaceteAR/blob/master/hex/ggplot2.png?raw=true) background-position: 95% 5% background-size: 10% # Las grillas de Argentina .pull-left[ ### **LatinR 2018** - [Abstract](https://github.com/TuQmano/geofacet_ARG/blob/master/.LatinR/Geofaceting_Argentina_RuizNicolini.pdf) #### [📊 Slides](https://www.researchgate.net/publication/327382101_Geofaceting_Argentina_LatinR_2018) #### [📦 {geofaceteAR}](https://electorarg.github.io/geofaceteAR/) #### [⌨️ blogpost](https://www.tuqmano.com/2020/05/22/empaquetar/) ] .pull-right[ <img src="clase8_files/figure-html/unnamed-chunk-16-1.png" width="504" style="display: block; margin: auto auto auto 0;" /> ] --- background-image: url(https://github.com/PoliticaArgentina/geoAr/raw/main/man/figures/logo.png) background-position: 95% 2% background-size: 15% # `geofacetAr` en `{geoAr}` ## `get_grid()` ```r (tucuman <- geoAr::get_grid(district = "TUCUMAN")) ## name_provincia name row col code ## 1 TUCUMAN BURRUYACU 1 4 013 ## 2 TUCUMAN CAPITAL 2 4 001 ## 3 TUCUMAN CHICLIGASTA 4 2 005 ## 4 TUCUMAN CRUZ ALTA 2 5 012 ## 5 TUCUMAN FAMAILLA 3 3 003 ## 6 TUCUMAN GRANEROS 5 4 009 ## 7 TUCUMAN JUAN B. ALBERDI 5 3 007 ## 8 TUCUMAN LA COCHA 6 3 008 ## 9 TUCUMAN LEALES 3 5 011 ## 10 TUCUMAN LULES 3 4 002 ## 11 TUCUMAN MONTEROS 3 2 004 ## 12 TUCUMAN RIO CHICO 4 3 006 ## 13 TUCUMAN SIMOCA 4 4 010 ## 14 TUCUMAN TAFI DEL VALLE 2 1 017 ## 15 TUCUMAN TAFI VIEJO 2 2 016 ## 16 TUCUMAN TRANCAS 1 3 014 ## 17 TUCUMAN YERBA BUENA 2 3 015 ``` --- background-image: url(https://github.com/PoliticaArgentina/geoAr/raw/main/man/figures/logo.png) background-position: 95% 2% background-size: 15% # `geofacetAr` en `{geoAr}` ```r geofacet::grid_preview(tucuman) ``` <img src="clase8_files/figure-html/unnamed-chunk-18-1.png" width="504" height="70%" /> --- background-image: url(https://github.com/PoliticaArgentina/geoAr/raw/main/man/figures/logo.png) background-position: 95% 2% background-size: 15% # `geofacetAr` en `{geoAr}` ## `recode_grid()` ```r tucuman %>% recode_grid(type = "indec") %>% geofacet::grid_preview() ``` <img src="clase8_files/figure-html/unnamed-chunk-19-1.png" width="504" height="70%" /> --- background-image: url(https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Leaflet_logo.svg/1200px-Leaflet_logo.svg.png) background-position: 95% 5% background-size: 20% ### Mapas interactivos [
`{leaflet}`](https://rstudio.github.io/leaflet/)
--- ### Mapas interactivos [
`{leaflet}`](https://rstudio.github.io/leaflet/) ```r library(geoAr) *library(leaflet) # tucson <- polAr::get_geo("TUCUMAN) leaflet(tucson) %>% #Dibuja Polygons * addPolygons() %>% #Agrega fondo * addProviderTiles(providers$Stamen.Toner) ``` --- background-image: url(https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Leaflet_logo.svg/1200px-Leaflet_logo.svg.png) background-position: 95% 5% background-size: 20% ### Dónde deberiamos estar ahora? ```r leaflet() %>% * #Dibuja MARCADOR * addMarkers(lng = -58.4469439, -34.5480059) %>% #Agrega fondo addProviderTiles(providers$OpenStreetMap) ```
--- background-image: url(https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Leaflet_logo.svg/1200px-Leaflet_logo.svg.png) background-position: 95% 5% background-size: 20% ### Dónde deberiamos estar ahora? ```r leaflet() %>% #Dibuja MARCADOR addMarkers(lng = -58.4469439, -34.5480059) %>% * #Agrega fondo con otro TILE * addProviderTiles(providers$Stamen.Watercolor) ```
--- background-image: url(https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Leaflet_logo.svg/1200px-Leaflet_logo.svg.png) background-position: 95% 5% background-size: 20% ### Capa de fondo disponible en `{geoAr}` ```r leaflet() %>% #Dibuja MARCADOR addMarkers(lng = -58.4469439, -34.5480059) %>% * #Agrega fondo con otro TILE * geoAr::addArgTiles() ```