Skip to content

Instantly share code, notes, and snippets.

@charliejhadley
Created January 23, 2018 12:39
Show Gist options
  • Save charliejhadley/2c6f55b280ebe80774cdf840f978e91f to your computer and use it in GitHub Desktop.
Save charliejhadley/2c6f55b280ebe80774cdf840f978e91f to your computer and use it in GitHub Desktop.
library("tidyverse")
journeys <- read_csv("data/clean-journeys.csv")
journeys %>%
count(start.country, date)
journeys %>%
group_by(start.country) %>% # hello!
select(end.country, number.of.letters) %>%
mutate(total.letters = sum(number.of.letters))
journeys %>%
group_by(start.country) %>% # hello!
summarise(total.letters = sum(number.of.letters)) %>%
arrange(desc(total.letters)) %>%
mutate(start.country = fct_reorder(start.country,
total.letters)) %>%
select(start.country) %>%
.[[1]]
journeys %>%
group_by(start.country) %>% # hello!
summarise(total.letters = sum(number.of.letters)) %>%
arrange(desc(total.letters)) %>%
mutate(start.country = fct_reorder(start.country,
total.letters)) %>%
ggplot(aes(x = start.country,
y = total.letters)) +
geom_col() +
coord_flip()
journeys %>%
group_by(start.country) %>% # hello!
summarise(total.letters = sum(number.of.letters)) %>%
ggplot(aes(x = start.country,
y = total.letters)) +
geom_col() +
coord_flip()
ggplot() +
geom_col(
data = journeys %>%
group_by(start.country) %>% # hello!
summarise(total.letters = sum(number.of.letters)),
aes(x = start.country,
y = total.letters)
) +
coord_flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment