1 ### COVID-19 Digital Observatory
4 ### Minimal example analysis file using pageview data
9 ### Import and cleanup one datafile from the observatory
12 url("https://covid19.communitydata.science/datasets/wikipedia/digobs_covid19-wikipedia-enwiki_dailyviews-20200101.tsv")
15 read.table(DataURL, sep="\t", header=TRUE, stringsAsFactors=FALSE)
17 ### Cleanup and do the grouping with functions from the Tidyverse
18 ### (see https://www.tidyverse.org for more info)
20 views <- views[,c("article", "project", "timestamp", "views")]
21 views$timestamp <- fct_explicit_na(as.character(views$timestamp))
24 ### Sorts and groups at the same time
25 views.by.proj.date <- arrange(group_by(views, project, timestamp),
28 ### Export just the top 10 by pageviews
29 write.table(head(views.by.proj.date, 10),
30 file="output/top10_views_by_project_date.csv", sep=",",
33 ### A simple visualization
34 p <- ggplot(data=views.by.proj.date, aes(views))
36 ## Density plot with log-transformed axis
37 p + geom_density() + scale_x_log10(labels=comma)