无法禁用gridExtra的R markdown输出(附加注释) [英] Cannot disable R markdown output from gridExtra (additional comment)

查看:284
本文介绍了无法禁用gridExtra的R markdown输出(附加注释)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的降价报告中,我使用了2个大块.

In my r markdown report i use 2 chunks.

第一:

```{r, include = FALSE, echo=FALSE, results='asis'}```

我在其中加载所有软件包并进行计算的地方.

Where i load all packages and do computation.

第二

{r, fig.margin = TRUE, fig.width=10,
fig.height=4.5, echo=FALSE, results='asis', 
message=FALSE, warning = FALSE} 

我在for循环中过滤第一个块中产生的数据,并对每个i进行ggplots.

Where i have for loop where I filter data I producent in first chunk, and make ggplots for each i.

我的问题是,当我在第二个块中生成2个图时,我将它们按grid.arrange组合在一个网格中,但是我不想显示其他注释.

My problem is that, when i produce 2 plots in second chunk i combine them in one grid by grid.arrange, but there is additional comment I don't want to show.

TableGrob (2 x 2) "arrange": 2 grobs
  z     cells    name           grob
1 1 (1-2,1-1) arrange gtable[layout]
2 2 (1-2,2-2) arrange gtable[layout]


title: "Test"
author: "Maybe It's You"
date: "2016.09.01"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(grid)
library(gridExtra)
library(ggplot2)

lay <- rbind(c(1,2),
             c(1,2))
gs <- list()

```


```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE, results='asis', message=FALSE, warning = FALSE}
p1 <- qplot(1:10)
p2 <- qplot(1:10)
gs[[1]] <- p1
gs[[2]] <- p2          


wykres <- grid.arrange(grobs = gs, layout_matrix = lay)
print(wykres)

```

带有gridExtra注释(TablGrob ...)的结果片段

推荐答案

不要print()grid.arrange()会自己绘制.如果要存储结果然后绘制,请使用arrangeGrob()+grid.draw()

don't print(), grid.arrange() draws by itself. If you want to store the result and then draw it, use arrangeGrob()+grid.draw()

这篇关于无法禁用gridExtra的R markdown输出(附加注释)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆