Created
August 14, 2018 17:33
-
-
Save Torvaney/acf57c067f02dd54193470bf1d7d6550 to your computer and use it in GitHub Desktop.
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(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