The goal of the vembedr package is to make it a little bit easier for you to embed videos into your rmarkdown documents and your shiny apps. Three services are currently supported: YouTube, Vimeo, and Microsoft Channel 9 (including UseR! 2016 and 2017 videos).

New to version 0.1.3


You can install the latest released version from CRAN with:


or the latest development version from GitHub with:

# install.packages("devtools")


For these examples, it can be useful to load the htmltools package along with the vembedr package.


With the function embed_url(), you can use the URL from your browser to embed video:


If you just want the embedding code, the suggest_embed() function may be useful:

#> embed_youtube("uV4UpCq2azs") %>%
#>   use_start_time("1m32s")

All of the features shown here can be used for all the supported services: YouTube, Vimeo, and Channel 9. Here, the features are mixed-and-matched in the interest of brevity.

To embed a YouTube (or Vimeo, or Channel 9) video you can use its identifier, which you can get from the original URL.


For this example, we embed a Vimeo using some custom formatting - thanks to Eric Koncina and Aurélien Ginolhac who showed the way. First let’s introduce some css where we can define some rounded corners for an embedded video, by describing an HTML class, vembedr:

.vembedr {
  display: inline-block;
  border-radius: 25px; /* adjust it to your needs */
  overflow: hidden;

.vembedr iframe {
  display: block;
  border: none;

To embed a Vimeo with some custom formatting:

embed_vimeo("189919038") %>%
  div(class = "vembedr") %>%
  div(align = "center")

Of course, the use of the pipe operator is optional. Hat tip to Karthik Ram for tweeting out this Vimeo.

You can also specify a start time. Please note that for Vimeo, specifying a start time implies that the video will be auto-played (which can be annoying).

Here’s an example using a lightning presentation from UseR!2017:

embed_user2017("Room-202-Lightning-Talks") %>% 

Note for GitHub README and RStudio viewer

The GitHub Markdown renderer does not support video embedding. To see everything in action, you are invited to visit the GitHub pages site, built using pkgdown.

If you use the RStudio-IDE viewer to preview your work, please note that RStudio have made the design choice not to allow arbitrary external web-content in the IDE, which is wholly appropriate. However, with the advent of the learnr package, the IDE-viewer supports embedding of Vimeo and YouTube videos.

Otherwise, you can simply open your preview in an external browser.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.