-
-
Save JuveCampos/3eae754b380fd5646a33a61ab4bc3a5d 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
### Grafica ---- | |
(plt <- ggplot(pop, aes(x = `Grupos quinquenales de edad`, | |
y = `Poblacion por Sexo`, | |
fill = Sexo)) + | |
# Seccion de HOMBRES | |
geom_col(data = subset(pop, Sexo == "Hombres") %>% | |
# Convertimos los datos de los Hombres en negativos | |
mutate(`Poblacion por Sexo` = -`Poblacion por Sexo`), | |
width = 0.5, fill = "blue") + | |
# Seccion de MUJERES | |
geom_col(data = subset(pop, Sexo == "Mujeres"), | |
width = 0.5, fill = "pink") + | |
# Cambio de ejes de coordenadas | |
coord_flip() + | |
scale_y_continuous( | |
breaks = c(seq(-100000, -20000, by = 20000), | |
seq(0, 100000, by = 20000)), | |
labels = c(seq(-100000, -20000, by = 20000) * -1, | |
seq(0, 100000, by = 20000))) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment