Building R Reports with Posit Team

Posit Solutions Engineering (Lisa Anders)

Posit, PBC

Building R Reports with Posit Team

“Illustration from Hadley Wickham’s talk”The Joy of Functional Programming (for Data Science).” by Allison Horst

What makes a good report?

Ideas?

What makes a good report?

Ideas?

  • Reproduceable

  • Easy to share

  • Pretty

Building reports programmatically is powerful!

Different report options

RMarkdown - Fully reproducible notebooks that weave together narrative text and code to produce formatted outputs.

Quarto - A new open-source scientific and technical publishing system that works with R, Python, Julia, Javascript, and many other languages.

Jupyter - Web application for sharing computational documents. (Not covered in today’s talk)

RMarkdowns

RMarkdown - Fully reproducible notebooks that weave together narrative text and code to produce formatted outputs.

RMarkdown documents are:

  • Easily accessible and testable to ensure accurate results every time
  • Easily version controlled
  • Easy to use with ample documentation and examples

RMarkdowns

General example:

RMarkdowns: Favorite packages

Blastula - Make it easy to send great looking HTML emails.

Flexdashboard - Flexible and easy to specify row and column-based layouts. Components are intelligently re-sized to fill the browser and adapted for display on mobile devices.

Connectwidgets - Query a Connect server for a subset of your existing content items, then organize them within htmlwidget components in an R Markdown document or Shiny application. (Not covered in today’s talk)

RMarkdowns: Parameterization

Parameterized Rmarkdown example:

When deploying the app it will need to have the source code included so that users can change the input parameter and re-render.

RMarkdowns: Sending emails with Blastula

Before:

Blastula example:

RMarkdowns: Sending emails with Blastula

After:

Blastula example:

RMarkdowns: Interactive dashboards with Flexdashboard

Flexdashboard - Flexible and easy to specify row and column-based layouts. Components are intelligently re-sized to fill the browser and adapted for display on mobile devices.

Flexdashboard example:

Quarto

quarto - A new open-source scientific and technical publishing system that works with R, Python, Julia, Javascript, and many other languages.

Quarto and RMarkdown work similarly, however Quarto was developed to be language agnostic and applied all the learnings from the development of RMarkdown.

Quarto documents

General example:

Quarto presentations

Code blocks can also be included in Quarto presentations:

Figure 1: Temperature and ozone level.

Quarto: Interactive images with Lightbox

Quarto with Python and lightbox example:

What if I’m coming from interactive reports, like Shiny?

Pros:

  • Better performance because everything is pre-calculated

  • Ecosystem of packages for displaying interactive content within static documents

Cons:

  • Computations won’t be happening real-time

    • Connect can schedule down to the minute - sometimes that can get you close enough to “real-time”
  • Less dynamic options

Blending static and interactive pieces of content can open up new workflows and reporting possibilities

Complex workflows

Complex workflows

tidymodels - The tidymodels framework is a collection of packages for modeling and machine learning using tidyverse principles.

vetiver - Vetiver provides fluent tooling to version, deploy, and monitor a trained model.

pins - The pins package publishes data, models, and other R objects, making it easy to share them across projects and with your colleagues.

plumber APIs - Plumber allows you to create a web API by merely decorating your existing R source code with roxygen2-like comments.

Complex workflows

pins - The pins package publishes data, models, and other R objects, making it easy to share them across projects and with your colleagues.

Pin example:

Where to go from here?

Happy Reporting!

Backup

Tools in the toolbox

RMarkdown - Fully reproducible notebooks that weave together narrative text and code to produce formatted outputs.

Blastula - Make it easy to send great looking HTML emails.

quarto - A new open-source scientific and technical publishing system that works with R, Python, Julia, Javascript, and many other languages.

Jupyter - Web application for sharing computational documents.