Created
May 15, 2020 22:23
-
-
Save bhive01/014dd24a4ffb919eb76c967c1414a478 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(knitr) | |
library(kableExtra) | |
library(ggtext) | |
library(tidyverse) | |
library(here) | |
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(.))) | |
render_one <- function(df) { | |
rmarkdown::render( | |
here('plot_num_test.Rmd'), | |
output_file = here("Large_num_plots_test_Experiment_Data_Summary.html"), | |
params = list(input_data = df) | |
) | |
} | |
large %>% | |
render_one(.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment