Skip to content

Instantly share code, notes, and snippets.

@aammd
Created January 12, 2016 20:13
Show Gist options
  • Save aammd/d1789f34c61b45f7d91c to your computer and use it in GitHub Desktop.
Save aammd/d1789f34c61b45f7d91c to your computer and use it in GitHub Desktop.
library(pageviews)
library(dplyr)
library(ggplot2)
bowie <- article_pageviews(article = "David_Bowie", end = "2016011200")
since_dec <- bowie %>%
mutate(timestamp = lubridate::ymd_h(timestamp)) %>%
filter(timestamp > lubridate::ymd("2015-12-01"))
since_dec %>%
mutate(endpt = "Including 11 Jan 2016") %>%
rbind({
since_dec %>%
filter(timestamp != lubridate::ymd("2016-01-11")) %>%
mutate(endpt = "Before 11 Jan 2016")
}) %>%
ggplot(aes(x = timestamp, y = views)) +
facet_wrap(~endpt, scales = "free") +
geom_line() +
theme_minimal() +
xlab("Date")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment