Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# 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