【问题标题】:YouTube Video in R markdownR markdown 中的 YouTube 视频
【发布时间】:2016-11-25 19:31:51
【问题描述】:

是否可以在 R Markdown 中嵌入 YouTube 视频? 到目前为止,我所拥有的是

<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 文档本身中播放视频?

参考资料: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#videos

【问题讨论】:

  • iframe 工作吗?

标签: r video youtube r-markdown


【解决方案1】:

接受的解决方案对我(2021 年)不起作用,但这个解决方案对我有用:

<iframe src="https://www.youtube.com/embed/6A5EpqqDOdk" data-external= "1" > </iframe>

【讨论】:

    【解决方案2】:

    我想答案可能就这么简单:

    ![](https://youtu.be/zNzZ1PfUDNk)
    

    【讨论】:

    • 这篇文章是为了提供 url 链接,并没有回答 OP 的问题,即“如何在 Rmd 中嵌入”链接
    【解决方案3】:

    您将需要使用 iframe。例如在基本 RMD 模板中添加 markdown 视频:

    ---
    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.
    

    请注意,视频不会出现在预览窗口中,但在连接到互联网的浏览器中观看时会出现。

    【讨论】:

      猜你喜欢
      • 2015-02-27
      • 1970-01-01
      • 2011-08-10
      • 1970-01-01
      • 2017-09-01
      • 2021-02-02
      • 2021-11-18
      • 1970-01-01
      • 2012-12-20
      相关资源
      最近更新 更多