Skip to content

Instantly share code, notes, and snippets.

@bhive01
Created May 15, 2020 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhive01/49b5777fafb4fe60e23b9fc275d1e50b to your computer and use it in GitHub Desktop.
Save bhive01/49b5777fafb4fe60e23b9fc275d1e50b to your computer and use it in GitHub Desktop.
---
title: 'Large Number of Plots Testt: `r glue::glue("blahblahblah")`'
author: "Test Person"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
html_document:
keep_md: false
toc: true
toc_float: true
toc_depth: 4
---
# Trial Design and Assessment
Need Trial Description information here
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(knitr)
library(ggtext)
library(tidyverse)
plot_data <- function(df) {
ggplot() +
geom_point(data = df, aes(x = wt, y = disp, colour = cyl), position = position_jitter(w = 0.8, h = 0)) +
labs(
x = "Weight (kg)",
y = "Displacement (cm<sup>3</sup>)",
caption = glue::glue("<br>Pink dots represent outliers and are removed from downstream analyses.<br>Error bars represent the standard error of the mean.<br>ANOVA model significance *p* < 0.05.<br>Treatments with the same letter are not significantly different at *α* = 0.05 according to Tukey's HSD. ")
) +
theme(
axis.title.y = element_markdown(), # utilize ggtext to add superscript for units
panel.grid = element_blank(), # get rid of background lines
plot.caption = element_textbox_simple() # utilize ggtext to add italics and wrap text
)
}
large <-
tibble(rep = 1:1200) %>%
mutate(
data = list(sample_n(as_tibble(mtcars), 25)),
plots = map(data, ~ plot_data(.)),
title = paste0("#### Version ", rep, " \n\n")
)
print_plots <- function(title, plot) {
cat(title)
print(plot)
cat(" \n\n")
}
```
```{r inputs, message=FALSE, warning=FALSE, error=FALSE, fig.retina=TRUE, fig.height=7, fig.width=8, results = 'asis'}
cat("### Trait Level Plots \n\n")
pwalk(list(large$title, large$plots), ~print_plots(..1, ..2))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment