Reimagining Literate Programming and Automated Report Generation

R Markdown, re-implemented in the spirit of minimalism

Yihui Xie

2024-09-12 @ University of Auckland (Ihaka Lecture Series)

An FAQ about me when I travel

Where is your baggage?

Asked by border control officers, taxi drivers, and friends…


[…] A wealthy businessman who was passing through Radin and took advantage of the opportunity to visit the Rabbi (Chofetz Chaim). He was astounded by the lack of furniture in Rabbi’s home.

Unable to contain himself, he asked, “Where is your furniture?”

Rabbi responded by asking him where was his furniture.

The man, a bit surprised by the question, explained that he was only passing through.

Rabbi smiled and explained that in this world, he too, was only passing through.1


Where is your Pandoc?

And jQuery?

Bootstrap?

Microsoft Office?

…?


The two richest men in Omaha, Nebraska

  1. Warren Buffet

  2. ???


Minimalism: my new journey




⚡ litedown ⚡

Make Markdown HTML Again

Do one thing, and do it well


In HTML I Trust

Quick tests for my audience today:

Italic tower HTML body End the war

How much fun you have missed without knowing HTML…


The impressive document converter


One road to Rome


Yes, SVG is awesome, but…

discovering svg in powerpoint


Someday you will realize…

Word and PowerPoint are just awkward implementations of HTML, CSS, and web browsers.

web browsers <- web browsers | MS Office -> microsoft office

And you will also realize how awesome web browsers are…

(now cast the spell “go up”, “go down”, “dark mode”, “mirror my slides”, or “reset my slides”)

BTW, did you notice that this slide is actually editable?


Demos

# install from CRAN
install.packages('litedown')
# or install the dev version (recommended for now)
install.packages('litedown', repos = c('https://yihui.r-universe.dev', 'https://cloud.r-project.org'))

Literate programming


Custom execution order of code

I don’t have enough time showcase all possibilities of litedown, so let me highlight one tiny feature that I came up with when rethinking about literate programming.

---
title: A nice report
abstract: "In this report, we studied `{r, order = -1} nrow(x)` cars."
---

Filter cars with `mpg` above 20.

```{r, order = 1}
x = subset(mtcars, mpg > 20)
```

Thank you!


  1. source

  2. litedown only depends on xfun and commonmark.

  3. Much stabler than Pandoc. Maintaining compatibility with new Pandoc releases has not been easy in R Markdown.

  4. With 500 blades?!