Skip to content

Instantly share code, notes, and snippets.

@Torvaney
Created August 14, 2018 17:33
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 Torvaney/acf57c067f02dd54193470bf1d7d6550 to your computer and use it in GitHub Desktop.
Save Torvaney/acf57c067f02dd54193470bf1d7d6550 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(rvest)
url <- "https://en.wikipedia.org/wiki/List_of_minimum_annual_leave_by_country"
clean_colnames <-
. %>%
str_to_lower() %>%
str_remove_all("\\[.*\\]") %>%
str_remove_all("\\(.*\\)") %>%
str_trim() %>%
str_replace_all("\\s", "_")
holidays_data <-
read_html(url) %>%
html_node(".wikitable") %>%
html_table() %>%
rename_all(clean_colnames) %>%
mutate(paid_public_holidays = as.integer(paid_public_holidays))
head(holidays_data)
countries <- c("United Kingdom", "France")
holidays_data %>%
filter(country_and_flag %in% countries) %>%
ggplot(aes(x = country_and_flag,
y = paid_public_holidays)) +
geom_col() +
labs(title = "Number of holiday days",
subtitle = "UK vs France",
x = NULL,
y = NULL) +
theme_minimal()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment