Created
July 10, 2017 15:37
-
-
Save robwschlegel/2b0324a4b88e0fa8a4c100dc3bcf91e4 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
# Top 10 goat having countries | |
goats_top <- goats %>% | |
arrange(desc(value)) %>% | |
filter(ccode %in% head(unique(ccode), 10)) | |
# Bottom 10 | |
goats_bottom <- goats %>% | |
arrange(value) %>% | |
filter(ccode %in% head(unique(ccode), 10)) | |
# Line graphs | |
gt <- ggplot(data = goats_top, aes(x = year, y = value)) + | |
geom_line(aes(colour = country.name)) + | |
labs(y = "Goats/ Capita", x = NULL) + | |
scale_x_continuous(expand = c(0,0)) + | |
scale_color_brewer(name = NULL, palette = "Set3") + | |
theme(legend.position = "top") | |
gb <- ggplot(data = goats_bottom, aes(x = year, y = value)) + | |
geom_line(aes(colour = country.name)) + | |
labs(y = "Goats/ Capita", x = NULL) + | |
scale_x_continuous(expand = c(0,0)) + | |
theme(legend.position = "bottom", | |
legend.title = element_blank()) | |
# Combine | |
grid.arrange(gt, gb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment