Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two chunks side by side with knitr markdown

With Rmarkdown, how could we do to get two chunk outputs side by side ?

I have naively tried this which doesn't work:

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span4">
```{r one, eval=TRUE, echo=FALSE}
......
......
```
        </div>
        <div class="span4">
```{r two, eval=TRUE, echo=FALSE}
......
......
```        
        </div>           
    </div>
</div>  

Actually, more precisely, I want to generate two figures side by side. I know this is possible with only one figure using mfrow() for classical plots or grid.arrange() for ggplots, but I'd like to include two html legends, one below each figure.

NB: I'm rather ignorant in HTML.

like image 627
Stéphane Laurent Avatar asked Oct 04 '13 14:10

Stéphane Laurent


People also ask

How do I plot side-by-side in R Markdown?

To place multiple figures side-by-side from the same code chunk, you can use the fig. show='hold' option along with the out. width option. Figure 2.5 shows an example with two plots, each with a width of 50% .

How do I add another chunk in r?

You can insert an R code chunk either using the RStudio toolbar (the Insert button) or the keyboard shortcut Ctrl + Alt + I ( Cmd + Option + I on macOS).


1 Answers

I found a similar question that provides some possible code solutions and a link to the Docco standard style, which shows a nice example:

2 Column Report in R Markdown - Render HTML aside Data Frame

like image 130
ano Avatar answered Sep 28 '22 07:09

ano