Skip to contents


Initialize Wikipedia Preview by including the following inline code anywhere in your R Markdown document:

`r wikipediapreview::wp_init()`

Note: If you prefer to have a designated chunk, initialize with the following code instead:

```{r wp-init, results='asis', echo=FALSE}


The library automatically detects Wikipedia links.


Sampling via [MCMC](


Sampling via MCMC

You can also make those links stand out and appear different from non-Wikipedia links using the built-in style:


[Stan]( samples via


Stan samples via HMC

Wikipedia Preview works with all the language editions of Wikipedia.


At the time of writing this vignette the article on
[Bayesian inference]({.wiki}
is available in 30 languages, including:

- Arabic: [استدلال بايزي]({.wiki}
- French: [Inférence bayésienne]({.wiki}
- Japanese: [ベイズ推定]({.wiki}


At the time of writing this vignette the article on Bayesian inference is available in 30 languages, including:

Alternative style

The default styling is the one provided and used by Wikimedia’s Inuka team which developed Wikipedia Preview. The author of this package prefers a different styling and has made it available via the use_alt_style flag when initializing:

`r wikipediapreview::wp_init(use_alt_style = TRUE)`

Wikipedia links will be marked with a W that looks similar to the Wikipedia logo.


By default wp_init() will embed the JavaScript code in the page. The Wikipedia Preview JavaScript library is available via a CDN – specifically unpkg. To use that instead of embedding for bandwidth and performance benefits:

`r wikipediapreview::wp_init(use_unpkg = TRUE)`