R Markdown 格式的 YouTube 视频 [英] YouTube Video in R markdown
问题描述
是否可以在 R Markdown 中嵌入 YouTube 视频?到目前为止,我所拥有的是
Is it possible to embed a YouTube video in a R Markdown? So far what I have is
<a href="http://www.youtube.com/watch?feature=player_embedded&v=Q8rakpF7duU
" target="_blank"><img src="http://img.youtube.com/vi/Q8rakpF7duU/0.jpg"
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
但它只添加了一个图像.单击此图像会将我带到开始播放视频的浏览器.有没有办法让我在 markdown 文档中播放视频?
but it only adds an image. Clicking on this image takes me to my browser where the video starts playing. Is there a way that allows me to play the video in the markdown document itself?
参考资料:https://github.com/adam-p/markdown-here/wiki/Markdown-备忘单#videos
推荐答案
您将需要使用 iframe.例如在基本 RMD 模板中添加 Markdown 视频:
You will need to use iframe. For example adding a markdown video to the basic RMD template:
---
title: "iframe"
author: "Example"
date: "22 July 2016"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
<iframe width="560" height="315" src="https://www.youtube.com/embed/6A5EpqqDOdk" frameborder="0" allowfullscreen></iframe>
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
请注意,视频不会出现在预览窗口中,但在连接到互联网的浏览器中查看时会出现.
Note that the video will not appear in the preview window but will when viewed in a browser connected to the internet.
这篇关于R Markdown 格式的 YouTube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!