Skip to content

Instantly share code, notes, and snippets.

@danielredondo
Last active July 3, 2020 08:28
Show Gist options
  • Save danielredondo/4e62720cdbb7e24dee6ed3238ae1643f to your computer and use it in GitHub Desktop.
Save danielredondo/4e62720cdbb7e24dee6ed3238ae1643f to your computer and use it in GitHub Desktop.
library(pageviews)
library(dplyr)
library(ggplot2)
# Leyenda no en formato científico
options(scipen = 10000)
# Lo más leído del mes de Junio
top <- top_articles(project = "es.wikipedia",
start = as.Date("2020-06-01"),
end = as.Date("2020-06-30")) %>%
filter(!grepl(":", article)) %>%
select(article) %>%
head(7) %>%
t %>%
as.vector()
top2 <- gsub(pattern = "_", replacement = " ", x = top)
print(top2)
datos <- article_pageviews(project = "es.wikipedia",
article = top2,
start = as.Date("2020-06-01"),
end = as.Date("2020-06-30"))
datos %>%
ggplot(aes(x = date, y = views, col = gsub(pattern = "_", replacement = " ", x = article))) +
geom_line(size = 1) +
ggtitle("Artículos más leídos de Wikipedia en Español durante Junio") +
scale_colour_discrete("") +
scale_x_datetime(date_breaks = "1 day", date_minor_breaks = "1 day") +
ylab("Número de visitas diarias") +
xlab("") +
theme_bw() +
theme(
axis.text = element_text(color = "black"),
axis.text.x = element_text(angle = 90, vjust = .5),
plot.title = element_text(size = 15, hjust = .5)
)
ggsave("g1.png", width = 14, height = 8)
# Coronavirus
datos <- article_pageviews(project = "es.wikipedia",
article = c("Pandemia_de_enfermedad_por_coronavirus_de_2019-2020", "COVID-19"),
start = as.Date("2020-06-01"),
end = as.Date("2020-06-30"))
datos %>%
ggplot(aes(x = date, y = views, col = gsub(pattern = "_", replacement = " ", x = article))) +
geom_line(size = 1) +
ggtitle("Coronavirus en la Wikipedia en Español") +
scale_colour_discrete("") +
scale_x_datetime(date_breaks = "1 day", date_minor_breaks = "1 day") +
ylab("Número de visitas diarias") +
xlab("") +
theme_bw() +
theme(
axis.text = element_text(color = "black"),
axis.text.x = element_text(angle = 90, vjust = .5),
plot.title = element_text(size = 15, hjust = .5)
)
ggsave("g2.png", width = 14, height = 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment