Views of the Wikipedia Gun Control Article, Before And After Two Mass Shootings (Las Vegas and New Zealand)
Libraries being used
library(tidyverse)
## -- Attaching packages ------------------------------------------------------------------------------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.1.0 v purrr 0.3.0
## v tibble 2.0.1 v dplyr 0.8.0.1
## v tidyr 0.8.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## -- Conflicts ---------------------------------------------------------------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(pageviews)
library(DT)
guns_ctrl <- article_pageviews(article = "Gun control", start = as.Date("2017-1-1"), end = as.Date("2019-03-17"))
Views of the Wikipedia Gun control Article
guns_ctrl %>%
ggplot(aes(x = date, y = views)) +
geom_line(color = "blue") +
theme_minimal() +
labs(x = "Date",
y = "Views",
title = "Views of the Wikipedia Gun control Article")

Data Table for Gun Control Article in Wikipedia
guns_ctrl %>%
select(date, views) %>%
arrange(-views) %>%
datatable()
Wikipedia views the day after Las Vegas shooting (01 October 2017).
lv_top_art <- top_articles(start = as.Date("2017-10-02")) %>%
select(article, views) %>%
filter(!article == "Main_Page", !article == "Special:Search") %>%
datatable()
lv_top_art
Wikipedia views the day after the Christchurch Mosque shootings (15-03-2019)
nz_top_art <- top_articles(start = as.Date("2019-03-16")) %>%
select(article, views) %>%
filter(!article == "Main_Page", !article == "Special:Search") %>%
datatable()
nz_top_art
Getting the data
vegas_shooting <- article_pageviews(article = "Gun_control",
start = as.Date("2017-9-24"),
end = as.Date("2017-10-15"))
vegas_shooting <- vegas_shooting %>%
mutate(day = -7:14) %>%
mutate(event = "Las Vegas")
NZ_shooting <- article_pageviews(article = "Gun_control",
start = as.Date("2019-2-24"),
end = as.Date("2019-3-17"))
NZ_shooting <- NZ_shooting %>%
mutate(day = -7:14) %>%
mutate(event = "New Zealand")
shootings <- bind_rows(vegas_shooting, NZ_shooting)
Comparing the two shootings
shootings %>%
ggplot(aes(x = day, y = views, color = event)) +
geom_line() +
theme_minimal() +
labs(x = "Days before/after shooting",
y = "Views",
title = "Views of the Wikipedia Gun control article, before/after two mass shootings")
