Created
July 9, 2019 15:11
-
-
Save zjuul/57ae0eaea6ed59dbcdbbbb02c3b4a925 to your computer and use it in GitHub Desktop.
Tour de France 2019 - plot general classification
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
library(httr) | |
library(jsonlite) | |
library(ggplot2) | |
library(dplyr) | |
# url with TDF standings | |
url <- "https://sportapi.widgets.sports.gracenote.com/cycling/getresult/classificationid/2148837/languagecode/1.json?c=64&module=cycling&type=classification" | |
standings <- fromJSON(content(GET(url), "text")[[1]]) | |
minutes <- 1.5 # only show riders that are this far behind the leader | |
ggplot(filter(standings, n_TimeRel/1000 < (60*minutes))) + | |
geom_bar(aes(x = reorder(c_Person, -n_TimeRel), y = n_TimeRel/1000), stat = "identity") + | |
coord_flip() + theme_minimal() + | |
xlab("") + | |
ylab("time difference in seconds") + | |
ggtitle(paste("Riders within", minutes, "minutes of leader - ", | |
nrow(filter(standings, n_TimeRel/1000 < (60*minutes))),"riders in TDF 2019")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment