在R Markdown中将图放置在图旁边(到pdf/乳胶) [英] Placing table next to plot in R Markdown (to pdf / latex)
问题描述
是否可以将由xtable
(或pander
)包生成的表和生成的图并排放置在R markdown中,编织成pdf,而文档的其余部分为不是?以下简单示例有望说明这一想法:
Is it possible to place a table generated with the xtable
(or alternatively the pander
) package and a generated plot side-by-side in R markdown knitting to pdf while the rest of the document is not in columns? The following simple example hopefully illustrates the idea:
\begin{multicols}{2}
```{r}
plot(cars)
```
```{r, results='asis'}
library('xtable')
print(xtable(head(cars,5)), type = "latex")
```
\end{multicols}
但是,这不会产生情节.我知道使用knitr存在解决方案(例如此处),但我没有让他们使用R降到pdf.
However, this does not produce the plot. I know that solutions exist using knitr (e.g. here) and for R markdown knitting to HTML (e.g. here) but I don't get them to work for R markdown to pdf.
推荐答案
gridExtra
包可用于此目的,而无需进入LaTeX地狱.将grid.arrange
功能用于并排图表和其他功能.
the gridExtra
package works for this without having to go into LaTeX hell. Use the grid.arrange
function for side by side charts and what-not.
处理html和PDF输出.
Works on html and PDF outputs.
这篇关于在R Markdown中将图放置在图旁边(到pdf/乳胶)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!