Skip to content

Commit b1f6251

Browse files
committed
Quarto as another reproducible document environment
1 parent 081d18d commit b1f6251

File tree

4 files changed

+44
-13
lines changed

4 files changed

+44
-13
lines changed

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ episodes:
7272
- 11-writing-data.Rmd
7373
- 12-dplyr.Rmd
7474
- 13-tidyr.Rmd
75-
- 14-knitr-markdown.Rmd
75+
- 14-reproducible-documents.Rmd
7676
- 15-wrap-up.Rmd
7777

7878
# Information for Learners
Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Producing Reports With knitr
2+
title: Producing Reproducible Reports
33
teaching: 60
44
exercises: 15
55
source: Rmd
@@ -44,8 +44,8 @@ game of fixing new mistakes resulting from a single formatting change.
4444
Creating a report as a web page (which is an html file) using R Markdown makes things easier.
4545
The report can be one long stream, so tall figures that wouldn't ordinarily fit on
4646
one page can be kept at full size and easier to read, since the reader can simply
47-
keep scrolling. Additionally, the formatting of and R Markdown document is simple and easy to modify, allowing you to spend
48-
more time on your analyses instead of writing reports.
47+
keep scrolling. Additionally, the formatting of and R Markdown document is simple and easy to modify,
48+
allowing you to spend more time on your analyses instead of writing reports.
4949

5050
## Literate programming
5151

@@ -62,9 +62,12 @@ be executed, and graphs or other results will be inserted into the final documen
6262

6363
This sort of idea has been called "literate programming".
6464

65-
`knitr` allows you to mix basically any type of text with code from different programming languages, but we recommend that you use `R Markdown`, which mixes Markdown
66-
with R. [Markdown](https://www.markdownguide.org/) is a light-weight mark-up language for creating web
67-
pages.
65+
`knitr` allows you to mix text with code from different programming languages,
66+
but we recommend that you use `R Markdown`, which mixes Markdown with R.
67+
[Markdown](https://www.markdownguide.org/) is a light-weight mark-up language for creating web pages.
68+
69+
You can either create `R Markdown` files directly or use
70+
[`quarto`](https://quarto.org/docs/computations/r.html) to create your documents.
6871

6972
## Creating an R Markdown file
7073

@@ -75,10 +78,25 @@ you'll get a dialog box like this:
7578

7679
You can stick with the default (HTML output), but give it a title.
7780

81+
## Creating a Quarto Document
82+
83+
Within RStudio, click File > New File > Quarto Document... and
84+
you'll get a dialog box like this:
85+
86+
![](fig/New_Quarto_Document.png){alt='Screenshot of the New Quarto Document dialogue box in RStudio'}
87+
88+
You can stick with the default (HTML output), but give it a title. Be
89+
sure to uncheck the visual editor checkbox and choose the Knitr engine.
90+
7891
## Basic components of R Markdown
7992

80-
The initial chunk of text (header) contains instructions for R to specify what kind of document will be created, and the options chosen. You can use the header to give your document a title, author, date, and tell it what type of output you want
81-
to produce. In this case, we're creating an html document.
93+
The initial chunk of text (header) contains instructions for R to specify
94+
what kind of document will be created, and the options chosen. You can use
95+
the header to give your document a title, author, date, and tell it what
96+
type of output you want to produce. In this case, we're creating an html
97+
document.
98+
99+
For an R Markdown document, you should get:
82100

83101
```
84102
---
@@ -89,6 +107,16 @@ output: html_document
89107
---
90108
```
91109

110+
For a Quarto document, you should get:
111+
112+
```
113+
---
114+
title: "Initial Quarto Document"
115+
author: "Karl Broman"
116+
format: html
117+
---
118+
```
119+
92120
You can delete any of those fields if you don't want them
93121
included. The double-quotes aren't strictly *necessary* in this case.
94122
They're mostly needed if you want to include a colon in the title.
@@ -181,7 +209,7 @@ the "Knit" button in the upper-left.
181209

182210
## Challenge 1
183211

184-
Create a new R Markdown document. Delete all of the R code chunks
212+
Create a new R Markdown or Quarto document. Delete all of the R code chunks
185213
and write a bit of Markdown (some sections, some italicized
186214
text, and an itemized list).
187215

@@ -191,7 +219,8 @@ Convert the document to a webpage.
191219

192220
## Solution to Challenge 1
193221

194-
In RStudio, select File > New file > R Markdown...
222+
For R Markdown in RStudio, select File > New file > R Markdown...
223+
and for Quarto in Rstudio, select File > New File > Quarto Document...
195224

196225
Delete the placeholder text and add the following:
197226

@@ -303,7 +332,7 @@ plot(lifeExp ~ year, data = gapminder)
303332

304333
## How things get compiled
305334

306-
When you press the "Knit" button, the R Markdown document is
335+
When you press the "Knit" button, the R Markdown or Quarto document is
307336
processed by [`knitr`](https://yihui.name/knitr) and a plain Markdown
308337
document is produced (as well as, potentially, a set of figure files): the R code is executed
309338
and replaced by both the input and the output; if figures are
@@ -480,7 +509,9 @@ This mode also includes a toolbar at the top with basic formatting buttons,
480509
similar to what you might see in common word processing software programs.
481510
You can turn visual editing on and off by pressing
482511
the ![](fig/visual_mode_icon.png){alt='Icon for turning on and off the visual editing mode in RStudio, which looks like a pair of compasses'}
483-
button in the top right corner of your R Markdown document.
512+
button in the top right corner of your R Markdown document or switching between
513+
the source and visual modes ![](fig/source_visual_buttons.png){alt='Buttons for changing between source and visual editing modes in RStudio'}
514+
in the top left of the RStudio window.
484515

485516
::::::::::::::::::::::::::::::::::::::::::::::::::
486517

47.6 KB
Loading
1.45 KB
Loading

0 commit comments

Comments
 (0)