Skip to content

Instantly share code, notes, and snippets.

@atyre2
Created February 2, 2018 19:35
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 atyre2/b564d163083fce83de4c0abe03c96b87 to your computer and use it in GitHub Desktop.
Save atyre2/b564d163083fce83de4c0abe03c96b87 to your computer and use it in GitHub Desktop.
library(rvest)
library(tidyverse)
webpage <- read_html("http://snr.unl.edu/aboutus/who/people/wellness/flightascendingsummary.asp")
tbls <- html_nodes(webpage, "table") %>%
html_table() %>%
.[[1]] %>%
separate(Participant, into = c("Last Name", "First Name"), sep = ",") %>%
mutate(`Flights per day` = `Total Number of Flights` / `Total Number of Days`,
`Last Name` = factor(`Last Name`)) %>%
mutate(`Last Name` = forcats::fct_reorder(`Last Name`, `Flights per day`))
ggplot(data = tbls,
mapping = aes(x = `Last Name`, y = `Total Number of Flights`, color=`Total Number of Days`)) +
geom_point() +
coord_flip() +
geom_hline(yintercept = 60, color="peachpuff2", linetype = 2) +
scale_color_distiller(palette = "PuRd", limits = c(1,28)) +
theme_classic(base_size = 11) +
theme(legend.position = "top") +
labs(caption = "Flights Ascending Leaderboard, Feb 2, 2018.\nSchool of Natural Resources, University of Nebraska-Lincoln")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment