2
votes

I'm trying to output a beamer_presentation in Rmarkdown, where I'd like to show a code chunk, and then, on click, show the figure as a result of that code chunk. I know "xarigan" package allows this fairly simply (--), but I'd prefer to use base Rmarkdown, for reproducibility purposes.

Example:

---
title: "Untitled"
author: "BP"
output: beamer_presentation
---

## Slide with Bullets

- Making a plot

    ```{r cars, echo= TRUE}
     plot(cars$speed, cars$distance)
    ```

Ideally, the presentation would show the bullet and the code chunk, and then, incrementally build the plot.

Thanks

1
I believe I have edited the code chunk to do so! - thebenjaminp

1 Answers

1
votes

You could modify the definition of the Shaded environment a bit

---
title: "Untitled"
author: "BP"
output: 
    beamer_presentation:
        keep_tex: true
header-includes:
   - \renewenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}\pause}        
---

## Slide with Bullets

- Making a plot

    ```{r cars, echo= TRUE}
     plot(cars$speed, cars$distance)
    ```

(if you don't want this for your whole document, do this in a group around your plot)