Skip to content

Instantly share code, notes, and snippets.

@jnolis
Created April 21, 2020 13:17
Show Gist options
  • Save jnolis/aad7879f235d44fe840895b7e977e435 to your computer and use it in GitHub Desktop.
Save jnolis/aad7879f235d44fe840895b7e977e435 to your computer and use it in GitHub Desktop.
Layout a grid of figures in an RMarkdown file
---
title: "Side-by-side images"
author: "Jacqueline Nolis"
date: "4/21/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(ggplot2)
```
```{r example, results="asis"}
cat("<div class=\"row\">")
for(i in 1:12){
cat("<div class=\"col-xs-4\">")
plot <- ggplot(cars,aes(x=speed,y=dist))+geom_point(position=position_jitter())
print(plot)
cat("</div>")
}
cat("</div>")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment