CrumpLab / psyc7709_2019

Course website for PSYC 7709 - Using R for Reproducible Research (taught by Matt Crump 2019)
https://crumplab.github.io/psyc7709_2019/
1 stars 7 forks source link

displaying multiple plots on a xaringan slide #17

Open TheTroyF opened 5 years ago

TheTroyF commented 5 years ago

This is my slide, it's meant to show how you can replicate data in multiple plots by using a function in r. The issue is, I can't fit multiple plots on one slide unless I make them very small.


class: center, inverse

Functional Programming

Rstudio treats all GGplot objects the same as regular r objects. You can add multiple geoms to the same base plot, giving you the user, a quick reference to multiple different visuals.

geoms <- list(
  geom_point(),
  geom_boxplot(aes(group = cut_width(displ, 1))),
  list(geom_point(), geom_smooth())
)
p <- ggplot(mpg, aes(displ, hwy))
lapply(geoms, function(g) p + g)