M. Siwik M. Siwik - 10 months ago 60
R Question

Cannot disable R markdown output from gridExtra (additional comment)

In my r markdown report i use 2 chunks.


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

Where i load all packages and do computation.

And second

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

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

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)

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


```{r 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)


Fragment of result with gridExtra comment (TablGrob...)

Pic of pdf.output


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