I am printing two graphs with ggplot in HTML R Markdown output, but I would like them to appear side by side. Is it possible? Can I set the size of the shapes?
So far, I can only print one after another. I also tried the animation function from the R Cookbook, but this distorts the graphics a lot ...
Thanks!
title: "HT Chip MiSeq/HiSeq Analysis"
date: "October 1, 2015"
output:
html_document:
highlight: haddock
theme: flatly
---
```{r plots, echo=FALSE}
genesDetectedDensity_MiSeq <- ggplot(meta.miseq) + geom_density(aes(genesDetected, fill=column, color=seqRun), alpha=0.2) + scale_x_continuous(limits=c(0,2000), breaks=seq(0, 2000, 100)) + ggtitle("Genes Detected across cells from MiSeq Runs")
return(genesDetectedDensity_MiSeq)
genesDetectedHistogram_MiSeq <- ggplot(meta.miseq) + geom_bar(aes(genesDetected, fill=column, color=seqRun), position="dodge", binwidth=50, alpha=0.2) + scale_x_continuous(limits=c(0,2000), breaks=seq(0, 2000, 100)) + ggtitle("Genes Detected across cells from MiSeq Runs")
return(genesDetectedHistogram_MiSeq)
```
This causes the following:
![enter image description here](https://fooobar.com//img/6225a3fbe2cc6decbf09c758ec550185.png)
UPDATE: Following the sentence I received below, I tried to use the library gridExtra
and printed the graphs, adding:
grid.arrange(genesDetectedDensity_MiSeq, genesDetectedHistogram_MiSeq, ncol=2)
This almost works, but it's still pretty messy:
![enter image description here](https://fooobar.com//img/0991967968a8c82cab7b13c2a7faeb38.png)