What's crawling and why is it useful?
Last updated
Last updated
library(dplyr)
library(rvest)
url <- "https://en.wikipedia.org/wiki/World_population"
population <- url %>%
read_html() %>%
html_nodes(xpath='//*[@id="mw-content-text"]/div[1]/table[7]') %>%
html_table() %>%
as.data.frame()
#removing extra row
population = population[-1,]
# convert to numeric
population$Population <- as.numeric(gsub(",","",population$Population))
population$Year <- as.numeric(population$Year)
library(ggplot2)
ggplot(population) +
aes(x = Year, y = Population) +
geom_point() +
theme_minimal() +
scale_y_continuous(labels = scales::comma)