【发布时间】:2016-12-03 05:18:56
【问题描述】:
我对即将推出的 RStudio 笔记本感到非常兴奋(在 preview version of RStudio 中提供。有关简短概述,请单击 here)。但是,我遇到了一些包含图片的困难。
在 Rmarkdown 中,我可以包含这样的图像:
---
title: "This works"
output: html_document
---
```{r echo=FALSE, out.width='10%'}
library(knitr)
knitr::include_graphics('https://www.rstudio.com/wp-content/uploads/2014/06/RStudio-Ball.png')
```
但是,当我想在笔记本中做同样的事情时(注意从 html_document 到 html_notebook 的变化),我不再得到图像:
---
title: "This does not work"
output: html_notebook
---
```{r echo=FALSE, out.width='10%'}
knitr::include_graphics('https://www.rstudio.com/wp-content/uploads/2014/06/RStudio-Ball.png')
```
(当我使用与笔记本相同文件夹中的图像时,我只需获取该图像的名称,就像指向外部图像的链接一样)。
我的问题:有没有办法在 rmarkdown 代码块内的笔记本 (update:) 中也显示图像?
请注意:我想使用 r-code 来包含图像。我不想包含带有标准降价 () 的图像,它在笔记本和常规 rmarkdown 文档中都有效。我也不想使用html。我希望使用 r-code 包含图像可以在笔记本中呈现图像。
编辑:常规 Rmarkdown 文件和笔记本之间的一个区别是笔记本是“预览的”而不是编织的:
【问题讨论】:
-
您想使用
r code或rmarkdown语法来获取图像吗?请确认 -
我想使用
r-code,最好是knitr::include_graphics() -
抱歉,我误读了您的陈述。我想将图像包含在 r-markdown 代码块中
-
哦,让我看看。因此,您想在 r 块中读取图像,并且当您编织 r 笔记本时通过 r markdown 时,图像应该在那里?对吗?
-
我想是的。澄清一下:我不编织笔记本,而是预览它。
标签: r rstudio knitr r-markdown