Reputation: 121
All solutions found using Google don't work for me. Can someone show me a simplest possible .Rmd
file that embeds a YouTube video?
According to R Markdown: The Definitive Guide something as simple as ![](https://youtu.be/zNzZ1PfUDNk)
should work. This post on SO tells me to use:
<iframe width="560" height="315" src="https://youtu.be/zNzZ1PfUDNk" frameborder="0" allowfullscreen></iframe>
My simple .Rmd
file with only these two snippets looks like this:
![](https://youtu.be/zNzZ1PfUDNk)
<iframe width="560" height="315" src="https://youtu.be/zNzZ1PfUDNk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
But knitted to an HTML I only get this:
What am I missing here?
Upvotes: 2
Views: 672
Reputation: 41
I had the exact same problem, but found the answer. You have to install the package "vembedr"
and then just write: embed_url("https://www.youtube.com/watch?v=BD_n6ju9iRA")
in a codechunk. Works perfectly if you or anybody still need it.
You can also get more information here: https://cran.r-project.org/web/packages/vembedr/vignettes/embed.html
Upvotes: 4