在Rmarkdown中将图像对象并排放置
有没有一种方法可以在Rmarkdown(html输出)中并排放置两个图像对象 理想情况下,我希望能够做到以下几点:在Rmarkdown中将图像对象并排放置,r,r-markdown,R,R Markdown,有没有一种方法可以在Rmarkdown(html输出)中并排放置两个图像对象 理想情况下,我希望能够做到以下几点: ```{r} library(ggplot2) library(data.table) dt<-data.table(a=1:10, b=1:10) gg <- ggplot(dt,aes(a,b)) + geom_line() ``` 并让它们并排出现在html中。我没有看到任何特定于Rmarkdown的内容,只有一些其他关于保存图像的建议,而不是我在这里展示的对
```{r}
library(ggplot2)
library(data.table)
dt<-data.table(a=1:10, b=1:10)
gg <- ggplot(dt,aes(a,b)) + geom_line()
```
并让它们并排出现在html中。我没有看到任何特定于Rmarkdown的内容,只有一些其他关于保存图像的建议,而不是我在这里展示的对象。下面是我如何安排三个绘图的
library(ggplot2)
library(gridExtra)
o1 <- ggplot(...)
o2 <- ggplot(...)
o3 <- ggplot(...)
# for Aligning Axes in ggplot2 see
# http://www.exegetic.biz/blog/2015/05/r-recipe-aligning-axes-in-ggplot2/
o2 <- ggplot_gtable(ggplot_build(o2))
o3 <- ggplot_gtable(ggplot_build(o3))
maxWidth = unit.pmax(o2$widths[2:3], o3$widths[2:3])
o2$widths[2:3] <- maxWidth
o3$widths[2:3] <- maxWidth
grid.arrange(o1, arrangeGrob(o2, o3, nrow=2),
ncol=2, widths=c(1, 2))
库(ggplot2)
图书馆(gridExtra)
o1以下是我如何安排三个图
library(ggplot2)
library(gridExtra)
o1 <- ggplot(...)
o2 <- ggplot(...)
o3 <- ggplot(...)
# for Aligning Axes in ggplot2 see
# http://www.exegetic.biz/blog/2015/05/r-recipe-aligning-axes-in-ggplot2/
o2 <- ggplot_gtable(ggplot_build(o2))
o3 <- ggplot_gtable(ggplot_build(o3))
maxWidth = unit.pmax(o2$widths[2:3], o3$widths[2:3])
o2$widths[2:3] <- maxWidth
o3$widths[2:3] <- maxWidth
grid.arrange(o1, arrangeGrob(o2, o3, nrow=2),
ncol=2, widths=c(1, 2))
库(ggplot2)
图书馆(gridExtra)
o1很好,谢谢。你知道在R中有没有类似的html小部件的方法?像dygraphs
包中的一个?它说只允许grob
。这很有效,谢谢。你知道在R中有没有类似的html小部件的方法?像dygraphs
包中的一个?它说只允许grob
。