From R Markdown to Quarto
rstudio::conf 2022
Andrew Bray
As you arrive, if you haven’t already, please get your machine configured using the steps found on the workshop website. Please assist your neighbors if they’re running into issues.
https://rstudio-conf-2022.github.io/rmd-to-quarto/materials/
Also, please be ready with Discord for discussions (you should have an invite in your email from the conference).
Take ~2 minutes to introduce yourself to your neighbors.
Please share …
Workshop schedule, slides, and exercises are at:
Everyone leaves with a document, slides, and a website.
Learn from one another.
Build an understanding of the big picture.
Day One
Day Two
Ask a question by opening a new discussion post:
https://github.com/rstudio-conf-2022/rmd-to-quarto/discussions
During an exercise, place a yellow sticky on your laptop if you’re good to go and a blue sticky if you want help.
Image by Megan Duffy
During polls, you can vote in a browser tab either on your laptop or your phone at
Code of Conduct
Please carefully review the Code of Conduct and COVID policies1 can be found at . Please review them carefully. RStudio requires that you wear a mask that fully covers your mouth and nose at all times in all public spaces. We strongly recommend that you use a correctly fitted N95, KN95, or similar particulate filtering mask; we will have a limited supply available upon request. You can report Code of Conduct violations in person, by email, or by phone. Please see the policy linked above for contact information.
Sweave
weaves together S/R and \(\TeX\)pandoc
converts between different document formatsknitr
a next gen Sweave for R and Markdownknitr::pandoc
added to leverage pandoc
flexible outputspandoc
functionality moved into new rmarkdown
. . . throughout, an ecosystem of R packages develops . . . (bookdown
, blogdown
, distill
, etc.)
Quarto is compute-agnostic. R Markdown requires R.
The ecosystem of R packages is replaced by a single framework.
blogdown
, xaringan
, workflowr
, papaja
) that haven’t yet been implemented in Quarto.Heavy users of such tools may want to stick with R Markdown.
Let’s kick the tires on Quarto!
Open up a new Quarto document using an HTML format
Click the Render button.
Look carefully through the source. What do you notice that’s different from what it would look like in an Rmd document? Discuss with your neighbor then post your answers to the discussion forum.
Render input file to various document formats.
Input
*.qmd
*.ipynb
*.md
*.Rmd
Format
html
pdf
revealjs
docx
ppt
Quarto is integrated into RStudio
Click in Editor pane of RStudio.
To get the materials for each part of this course packed in an RStudio Project, run:
You can also
git clone
if you prefer that workflow.
HTML
LATEX
HTML
LATEX
Let’s focus on using quarto
at the command line. Within RStudio, this can be done in the Terminal tab in the Console pane.
ex-1.qmd
to html
and view the html file in an editor. How is the list expressed in html?ex-1.qmd
to latex
and view the latex file in an editor. How is the list expressed in latex?ex-1.qmd
to pdf
but specify that you want to output to a file named handout.pdf
. (see the helpfile for render
by typing quarto render --help
)ex-1.qmd
to be .md
and .Rmd
and re-rendering. Does the output differ?quarto --help
.A quick way to find out how Pandoc will convert: https://pandoc.org/try/.
A document consists of content, structure, appearance, format.
A document is a list of block elements that contain inline elements or other blocks, along with associated metadata.
A document is a list of block elements that contain inline elements or other blocks, along with associated metadata.
Starts on a new line and followed by an empty line. Forms a visible block.
Block 1
Block 2
Block 3
Examples:
A document is a list of block elements that contain inline elements or other blocks, along with associated metadata.
Modifies content inline and is not followed by a new line.
Block 1
Inline 1
Inline 2
Block 3
Examples:
A document is a list of block elements that contain inline elements or other blocks, along with associated metadata.
Ancillary info about the document’s origin, format, look, etc.
Metadata
Block 1
Inline 1
Inline 2
Block 3
Examples:
A document is a list of block elements that contain inline elements or other blocks, along with associated metadata.
Header
Paragraph
Emphasis
Image
Markdown is designed to be easy to write, and, even more importantly, easy to read:
A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.
-John Gruber
Whenever I hear “Pandoc”, I picture . . .
Via giphy.
Which of the following forms of text formatting are possible in pandoc markdown?
Please respond at pollev.com/rmdtoquarto.
Markdown allows you to format text with emphasis and strong emphasis. You can also add superscripts2, subscripts2, and display code verbatim
. Little known fact: you can also strikethrough text and present it in small caps.
1
The area of a circle is \(A = \pi r^2\), where \(r\) is the radius and \(\pi\) is the constant \(3.141592\ldots\).
TeX math lives between two $
. Opening $
must have a non-space character immediately to its right, while the closing $
must have a non-space character immediately to its left, and must not be followed immediately by a digit.
You can embed links with names, direct urls like https://quarto.org/, and links to other places in the document. The syntax is similar for embedding an inline image: .
Placement of the actual footnote depends on the format: end of page for pdf, end of doc for HTML, bottom of slide for presentations.
One or more lines of text followed by one or more blank lines.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor.
Markdown Syntax | Output |
---|---|
|
Header 1 |
|
Header 2 |
|
Header 3 |
|
Header 4 |
|
Header 5 |
|
Header 6 |
Can use *
, -
, or +
may be used for unordered list items.
Which of the following will render to the output on the right?
A
C
B
D
I once has a sandwich.
It was deliiiicous.
I then had coffee.
It gave me joy.
Please respond at pollev.com/rmdtoquarto.
“A list item may contain multiple paragraphs and other block-level content. Subsequent block elements must be preceded by a blank line and indented to line up with the first non-space content after the list marker.”
“The first list item with a @
marker will be numbered 1., the next 2., etc. The numbered examples need not occur in a single list; each new list using @
will take up where the last stopped.”
Explanation of examples.
You can also label your examples:
(@goodname)
.
A larger equation:
\[ f(x)=\sqrt{\frac{\tau}{2\pi}} e^{-\tau (x-\mu )^{2}/2} \]
This breaks it:
$$
{x} = _{i=i}^n x_1 $$
For “display” math, use $$
delimiters. The delimiters may be separated from the formula by whitespace. No blank lines between the opening and closing $$
delimiters.
Block images use the same syntax as inline images.
Images on their own line become a block:
or do they?
Images behave mostly like inline elements but often live in a dedicated block (e.g. a paragraph). Their behavior depends on output format.
Which of the following are valid ways to include metadata with a document?
Please respond at pollev.com/rmdtoquarto.
Metadata can be included via YAML (YAML Ain’t Markup Language).
Some syntax rules:
key: value
:
must be quoted-
|
Inside ex-2.qmd
you’ll find all of the content needed to create the output files ex-2-goal.html
and ex-2-goal.pdf
. Add into ex-2.qmd
the markdown syntax needed to create the various inline and block elements found in the output documents.
Inline
Block
For reference, see: https://pandoc.org/MANUAL.html#pandocs-markdown