使用Knitr并排插入png图像 [英] insert side by side png images using knitr
本文介绍了使用Knitr并排插入png图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在创建html文档时,如何将计算机中的png文件插入到rstudio中?
How can I insert side by side png files from my computer into rstudio when creating an html document?
以下方法效果很好(图)
The following works well (plots)
```{r, echo=FALSE,fig.width=4, fig.show='hold'}
plot(cars)
plot(rnorm(100))
```
但是对于来自路径的图像,仅显示最后一张图像
But for images from a path, only the last image is displayed
```{r fig.width=3, fig.show='hold'}
library(png)
img <- readPNG("C:/path to my picture/picture.png")
grid.raster(img)
img2 <- readPNG("C:/path to my picture/picture2.png")
grid.raster(img2)
```
推荐答案
您应该学习Markdown的语法(确实需要大约五分钟).该解决方案甚至根本不涉及R:
You should learn the syntax of Markdown (really, you need about five minutes). The solution does not even involve R at all:
![](path/to/picture.png) ![](path/to/picture2.png)
顺便说一句,您最好避免使用绝对路径.使用相对路径(相对于Rmd文件).
BTW, you'd better avoid absolute paths. Use relative paths (relative to your Rmd file).
这篇关于使用Knitr并排插入png图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文