Download Wikipedia daily page views for any language, using the Wikimedia REST API.

wikipedia_pageviews(
  articles,
  date_range = last_6_months(),
  language = "nl",
  platform = c("all-access", "mobile-web", "mobile-app", "desktop"),
  agent = c("all-agents", "user", "spider", "automated")
)

Arguments

articles

Titles of Wikipedia articles

date_range

defaults to last_6_months()

language

defaults to "nl" for the Dutch Wikipedia

platform

defaults to "all-access". More reliable for epidemic trends might be "mobile-web".

agent

defaults to "all-agents"

Examples

wikipedia_pageviews("Griep")
#> # A tibble: 184 × 3
#>    article date       views
#>    <chr>   <date>     <int>
#>  1 Griep   2024-08-01    40
#>  2 Griep   2024-08-02    28
#>  3 Griep   2024-08-03    32
#>  4 Griep   2024-08-04    24
#>  5 Griep   2024-08-05    26
#>  6 Griep   2024-08-06    41
#>  7 Griep   2024-08-07    37
#>  8 Griep   2024-08-08    32
#>  9 Griep   2024-08-09    37
#> 10 Griep   2024-08-10    40
#> # ℹ 174 more rows

articles <- c("Griep", "Koorts", "Hoest", "Verkoudheid", "Influenzavirus A",
              "Respiratoir syncytieel virus", "Keelpijn", "SARS-CoV-2")

if (require("certeplot2") && require("certestats") && require("dplyr")) {
  articles |>
    wikipedia_pageviews(c("2024-07-01", "2025-02-01")) |>
    group_by(article) |>
    mutate(z = z_score(views),
           z_ma = moving_average(z, w = 7, side = "left")) |>
    plot2(
      x = date,
      y = z_ma,
      category = article,
      type = "line",
      category.sort = "freq-asc",
      legend.position = "right",
      y.title = "7-daagse Z-score",
      x.title = "",
      title = "Wikipedia bezochte pagina's",
      subtitle = "Z-scores respiratoire seizoen")
}
#> Loading required package: certeplot2
#> Loading required package: plot2
#> 
#> Attaching package: ‘plot2’
#> The following objects are masked from ‘package:certetoolbox’:
#> 
#>     big_mark, dec_mark
#> Loading required package: certestats
#> 
#> Attaching package: ‘certestats’
#> The following objects are masked from ‘package:stats’:
#> 
#>     IQR, fivenum, median, quantile, sd, var
#> The following objects are masked from ‘package:base’:
#> 
#>     all, any, max, mean, min, pmax, pmin, prod, range, sum
#>  Applying category.sort = "freq-asc" using summarise_function = sum
#>  Using x.date_breaks = "2 months" based on data
#>  Using x.date_labels = "mmm yyyy" based on data