Skip to content

Instantly share code, notes, and snippets.

@DarwinAwardWinner
Last active February 1, 2017 21:22
Show Gist options
  • Save DarwinAwardWinner/1a949c5b5bdff205e869e82fea6e16ce to your computer and use it in GitHub Desktop.
Save DarwinAwardWinner/1a949c5b5bdff205e869e82fea6e16ce to your computer and use it in GitHub Desktop.
Example of a Rmd file that produces 10 plots labeled A-J. They appear in random order in RStudio's notebook.
---
title: "Random Plot Order Test"
author: "Ryan C. Thompson"
date: "February 1, 2017"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r load_pkgs}
library(magrittr)
library(dplyr)
library(ggplot2)
```
These plots should appear in random order in the RStudio Notebook interface.
```{r random_plots}
mydata <- data_frame(x=1:10, y=x+rnorm(length(x)))
p <- mydata %$% qplot(x, y)
titles <- sprintf("Plot %s", LETTERS[1:10])
plots <- lapply(titles, function(title) p + ggtitle(title))
print(plots)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment