gpt4 book ai didi

r - R Markdown 中的 YouTube 视频

转载 作者:行者123 更新时间:2023-11-28 21:39:10 26 4
gpt4 key购买 nike

是否可以在 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。例如将 Markdown 视频添加到基本 RMD 模板:

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

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

关于r - R Markdown 中的 YouTube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38517236/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com