From R Markdown to Quarto
UC Berkeley
Duke University + Posit
While you wait for the workshop to begin, be sure you’ve got all the tools needed for the workshop:
The American Statistical Association (ASA) is committed to providing an atmosphere in which personal respect and intellectual growth are valued and the free expression and exchange of ideas are encouraged. Consistent with this commitment, it is the policy of the ASA that all participants in ASA activities enjoy a welcoming environment free from unlawful discrimination, harassment, and retaliation. We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to, members of any race, ethnicity, culture, national origin, color, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
Model and support the norms of respect necessary to promote the conditions for healthy exchange of scientific ideas.
In speech or conduct, do not insult or disparage other participants.
Be conscious of hierarchical structures, specifically the existence of stark power differentials between students, early career statisticians and established career statisticians—noting that fear of retaliation from more established statisticians can make it difficult for students and early career statisticians to express discomfort, rebuff unwelcome advances, and report violations of the conduct policy.
Be sensitive to indications that may suggest that individuals are feeling unwelcome.
Please share:
02:00
These materials are pitched at someone who:
knows some R + Markdown
has worked in RStudio
wants to learn about Quarto
I’ll teach you
More Markdown
New Quarto formats
New Quarto projects
My turn: Lecture segments + live coding
Our turn: Live coding + follow along
Your turn: Exercises
1. Software: Download and install the latest versions of R, RStudio, and Quarto:
2. R Packages: Install the following packages:
3. Exercises: Download and open the exercises for this session. The easiest way is to run this line of R code at the console in RStudio.
Let’s get started!
With Quarto you can weave together narrative text and code to produce elegantly formatted output as documents, web pages, blog posts, books and more.
just like R Markdown…
but not just like it, there’s more to it…
Sit back and enjoy!
Open hello-penguins.qmd
in RStudio and with the visual editor
. . .
10:00
Introducing the Quarto CLI
Quarto is a command line interface (CLI) that renders plain text formats (.qmd
, .rmd
, .md
) OR mixed formats (.ipynb
/Jupyter notebook) into static PDF/Word/HTML reports, books, websites, presentations and more.
andrewbray$ quarto --help
Usage: quarto
Version: 1.3.340
Description:
Quarto CLI
Options:
-h, --help - Show this help.
-V, --version - Show the version number for this program.
Commands:
render [input] [args...] - Render files or projects to various document types.
preview [file] [args...] - Render and preview a document or website project.
serve [input] - Serve a Shiny interactive document.
create [type] [commands...] - Create a Quarto project or extension
create-project [dir] - Create a project for rendering multiple documents
convert <input> - Convert documents to alternate representations.
pandoc [args...] - Run the version of Pandoc embedded within Quarto.
run [script] [args...] - Run a TypeScript, R, Python, or Lua script.
add <extension> - Add an extension to this folder or project
install [target...] - Installs an extension or global dependency.
publish [provider] [path] - Publish a document or project. Available providers include:
check [target] - Verify correct functioning of Quarto installation.
help [command] - Show this help or the help of a sub-command.
knitr
or jupyter
evaluates R/Python/Julia code and returns a .md
file along with the evaluated code.md
file by Pandoc and converted to a final output formatquarto render
:quarto render
, andquarto_render()
.03:00
Quarto comes “batteries included” straight out of the box
revealjs
)Feature | R Markdown | Quarto |
---|---|---|
Basic Formats | ||
Beamer | beamer_presentation | beamer |
PowerPoint | powerpoint_presentation | pptx |
HTML Slides | revealjs | |
Advanced Layout | Quarto Article Layout |
Feature | R Markdown | Quarto |
---|---|---|
Cross References | Quarto Crossrefs | |
Websites & Blogs | ||
Books | bookdown | Quarto Books |
Interactivity | Shiny Documents | Quarto Interactive Documents |
Journal Articles | rticles | Journal Articles |
Dashboards | flexdashboard | Coming soon! |
In RStudio, go to File > New File > Quarto document to create a Quarto document with HTML output. Render the document, which will ask you to give it a name – you can use my-first-document.qmd
.
Use the visual editor for the next steps.
Add a title and your name as the author.
Create two sections, one with things you would like to use Quarto for and a second with your favorite thing about R.
Add a table of contents.
Stretch goal: Change the html theme to sketchy
.
05:00
You can render existing R Markdown documents with Quarto and you can rename them to .qmd
files to turn them into Quarto documents.
You don’t have to do this – R Markdown continues to be maintained.
However, Quarto
Offers “batteries included” shared syntax across formats
Allows you to choose your own editor and your preferred data science language
Comes with richer features out of the box
Is actively developed
Any questions / anything you’d like to review before we wrap up this module?
Where does the name “Quarto” come from?