MichalLauer / unriddle

R package that unriddles code in revealjs presentations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unriddle

CRAN status R-CMD-check

The goal of unriddle is to take a code that is a riddle, look at it step-by-step and unriddle it. To do that, reveal.js and quarto needs to be used.

Installation

You can install the development version of unriddle from GitHub with:

# install.packages("devtools")
devtools::install_github("MichalLauer/unriddle")

How to use

To enable this package, it only needs to be loaded at the beginning of your quarto reveal.js presentation.

---
title: My super-duper presentation
author: Michal Lauer
format: revealjs
---
```{r include=F, message=F, warning=F}
library(unriddle)
```

After that, unriddling can be easily enabled using chunk parameters. For example, consider the following code:

```{r mtcars-plot, unriddle=TRUE}
mtcars |> #break 
  ggplot(aes(x = factor(cyl), y = disp)) +
  geom_col() + #break
  theme_bw()
```

This will create three different slides. On the first one, only mtcars will be showed. The second slide adds the geom_col layer, and finally, the third one shows the chart with additional theme_bw.

Assumptions

To unriddle a code chunk, two assumptions must be met.

  1. The chunk has a unique name.
  2. The unriddle parameter is set to true, e.g. unriddle=TRUE.

You can then add custom #break comments to split your chunk into multiple slides. A brief showcase can be seen here.

Acknowledgements

First, I want to thank to my precious girlfriend Terezka who puts up with my night sessions and nerdy fun-facts about R.

This package is primarily inspired by the flipbookr package that does basically the same thing. When building this package, I tried to leverage more the strengths of the knitr package as well as some javascript. Hopefully, this will make contributing easier as the complexity of this package is (in my opinion) much smaller. However, props to Eva for making the original stuff!

About

R package that unriddles code in revealjs presentations

License:Other


Languages

Language:R 100.0%