Automatic Reporting

R Markdown / Quarto

ARTbio Team

2024-02-07

Short Introduction

What is R Markdown / Quarto

File formats for making dynamic documents with R and/or other languages (Python, Julia, C, Bash, CSS, etc.).


Both:

  • use markdown syntax (markup language that you can use to add formatting elements to plaintext text documents)
  • contain chunks of embedded codes

Minimal Elements…



---
title: "Automatic Report"
output: html_document
---

This is an **R Markdown** document.

## A Title

You can embed an R code chunk like this:

```{r}
summary(cars)
```
  1. Always starts with a YAML header surrounded by ---

  2. Following by:

  • Text written in markdown, e.g.:
    • # header level 1
    • **bold**
    • bullet-list
    • inline code
  • Chunks of code surrounded by ``` with code type indicated within {}.

Examples

Slight difference: YAML key: value pairs, chunk notation.

Outputs

Output Formats

  • Documents: HTML, PDF, MSWord
  • Presentations: PowerPoint, Revealjs (the current slides^^), etc.
  • Manuscripts (templates for various journals and publishers)
  • Books
  • Websites

Check out the full list in the Quarto’s guide and R Markdown formats from RStudio.

Writing Strategy

  • all-in-one

  • keep analysis in independent scripts, use R Markdown / Quarto to read and show results

Which to Choose?

With Quarto Coming, is R Markdown Going Away? No. – A blog of Yihui Xie

  • Quarto: multi-language support, easy cross-referencing, under active development (new features / bugs)
  • R Markdown: a bit more friendly to beginners, stable

Let’s Try!

RStudio Server

References

  • https://quarto.org/
  • https://rmarkdown.rstudio.com
  • https://shiny.posit.co/r/articles/build/rmarkdown/
  • https://intro2r.com/what-is-r-markdown.html#
  • https://bookdown.org/yihui/rmarkdown-cookbook/other-languages.html
  • https://quarto.org/docs/faq/rmarkdown.html
  • https://yihui.org/en/2022/04/quarto-r-markdown/
  • https://www.youtube.com/watch?v=i6rajzMkpD0