12

I am trying to publish a .Rmd in Rpubs by embedding a YouTube video link. After some exploration, I am trying the following which just gives a blank space in my html.

<div align="center">
   <iframe width="560" height="315" src="http://www.youtube.com/embed/zsYjsgm4Psg" frameborder="0" allowfullscreen>
   </iframe>
</div>

Two related posts:

  1. rmarkdown: Alter Action Depending on Document
  2. R markdown Embedded Youtube Video
Hack-R
  • 22,422
  • 14
  • 75
  • 131
S Das
  • 3,291
  • 6
  • 26
  • 41

2 Answers2

14
<iframe width="560" height="315" src="http://www.youtube.com/embed/9bZkp7q19f0?rel=0" frameborder="0" allowfullscreen></iframe>

This can optionally be put inside a code chunk within your .Rmd

Source

Hack-R
  • 22,422
  • 14
  • 75
  • 131
  • Why would you put the HTML code in an code chunk? For me it works, if I simply put the HTML line in an `.Rmd` file. Publishing on Rpubs worked as well. – Stibu Dec 31 '14 at 09:20
  • @Stibu you don't strictly have to put it in a chunk, the original author did that as a matter of style for presenting it. – Hack-R Dec 31 '14 at 14:28
1

On you tube, I tried using the link for sharing, https://youtu.be/....

But instead find "embed" under where you tube gives the share link. This give the tag you need and the right link, it is not the same has you would use in an tag.

Mike Seman
  • 46
  • 2