Skip to content

Instantly share code, notes, and snippets.

@robwschlegel
Created July 10, 2017 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robwschlegel/2b0324a4b88e0fa8a4c100dc3bcf91e4 to your computer and use it in GitHub Desktop.
Save robwschlegel/2b0324a4b88e0fa8a4c100dc3bcf91e4 to your computer and use it in GitHub Desktop.
# 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