Last active
June 20, 2019 20:51
-
-
Save gonzalezgouveia/a258a54b5eca54b4b1c3b0adcd0b1569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hecho con gusto para #DatosDeMiercoles, propuesto por @R4DS_es | |
# Por Rafa @GonzalezGouveia --> https://bit.ly/2Fnvc7V | |
# intalar paquete (si no los tienes) | |
library(tidyverse) | |
library(ggthemes) | |
# install_packages("readr") | |
leyes <- readr::read_csv("https://bit.ly/2x8ygQR") | |
# creando dataframe para paises de hispanos-latinos | |
leyes_latam <- leyes %>% | |
filter(pais_es %in% c('Argentina', | |
'Brasil', | |
'Colombia', | |
'Ecuador', | |
'España', | |
'México', | |
'Nicaragua', | |
'Perú', | |
'Uruguay', | |
'Venezuela')) %>% | |
select(pais_es, | |
matrimonio = reconocimiento_matrimonio, | |
union_civil = reconocimiento_union_civil, | |
adopcion_conjunta = reconocimiento_adopcion_conjunta, | |
adopcion_segundo_padre = reconocimiento_adopcion_segundo_padre) %>% | |
gather('reconocimiento','reconoce',2:5) | |
# cambiando el nombre de los factores | |
leyes_latam$reconoce <- factor(leyes_latam$reconoce, | |
levels = c("0","1"), | |
labels = c("no","si")) | |
# APRENDE más sobre factores en R en este video de YouTube! | |
# copia y pega el link en tu navegador --> https://bit.ly/31Kb7lN | |
leyes_latam %>% | |
ggplot(aes(x = reconocimiento, y = pais_es, fill = reconoce)) + | |
geom_tile(colour = "white", size = 2) + | |
theme_gdocs() + | |
theme(axis.text.x = element_text(size = 12, | |
angle = 45, | |
hjust = 1), | |
axis.title = element_blank()) + | |
ggtitle('Qué país reconoce qué?') | |
# comenta un emoji de piña en el tweet si lograste crear la gráfica! | |
# regresar al tweet --> https://bit.ly/2WYOeMP | |
ggsave('reconocimiento.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment