Limitations of R Markdown?

I can successfully create 4 plots with ggplot. Then, I can use patchwork to create 1 image that is a 4-blocker incorporating all 4 charts. I can successfully render these results to PowerPoint.

Now, here is the real question (and I am afraid of the answer.)

  1. suppose I want to keep the 4-block scheme but I want to have charts in the top 2 blocks and 1 chart on the lower left block AND text corresponding to the charts in the lower right block. Is this something that R Markdown or Patchwork can handle? Similar permutations would be useful as well, for example, 1 chart in top left and 1 chart in top right with corresponding text in the bottom half of the slide. Similarly, could have chart on upper left and lower left with right half used for text.

If you're going the patchwork route here, then it's really not an issue of R Markdown. You'll be able to render any patchwork object you can create in R to PPT.

As far as patchwork plot layouts, there are wonderful vignettes on the patchwork website that I would encourage you to explore.

Here for example are three plots with one block of text. I'm using the gridtext package to insert the text. Check out the documentation of gridtext to see the options for text rendering -- it's quite flexible.

library(patchwork)
library(ggplot2)
library(gridtext)

point <- ggplot(iris, aes(Sepal.Length, Petal.Length)) +
  geom_point()

bar <- ggplot(iris, aes(Petal.Width)) +
  geom_histogram()

box <- ggplot(iris, aes(Species, Sepal.Width)) +
  geom_boxplot()

text <- richtext_grob("These are my 3 plots!!")

(point + bar) / (box + text)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2020-03-03 by the reprex package (v0.3.0)

2 Likes

Dude - how did you become so awesome? You need a patreon site so you can charge for your solutions! Can’t wait to check this out tomorrow. Thanks again!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.