Created
January 3, 2020 14:17
-
-
Save shuckle16/9f0674630dd0b09c34598b081fe26eb0 to your computer and use it in GitHub Desktop.
scrapes wikipedia tourism table, makes chart
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) | |
library(magrittr) | |
kor_tour <- | |
read_html("https://en.wikipedia.org/wiki/Tourism_in_South_Korea") %>% | |
html_nodes('table') %>% | |
extract2(4) %>% | |
html_table() | |
kor_tour <- | |
kor_tour %>% | |
rename( | |
year = Year, | |
num_tourists = `Number of international visitorarriving in S. Korea`, | |
pct_change = `% change fromprevious year`) | |
kor_tour %>% | |
mutate(num_tourists = str_replace_all(num_tourists,",","")) %>% | |
mutate_all(as.numeric) %>% | |
ggplot(aes(x = year, y = num_tourists)) + | |
geom_point() + | |
geom_line() + | |
scale_y_continuous(label = scales::comma) + | |
ylab("Number of International Visitors to South Korea") + | |
xlab("Year") + | |
ggtitle( | |
label = "Tourism to South Korea Has Tripled Since 2003", | |
subtitle = "Source: Wikipedia (https://bit.ly/2EhEemh)" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment