OHSU-PSU School of Public Health
2025-07-17
.qmd)Two options:
Pop-up window selections:
HTML output format (default)KnitrUse visual markdown editorCreate
.qmd)Create, you should then see the following in your editor window:.qmd)File -> Save,We create the html file by rendering the .qmd file.
Two options:
Note
.qmd file 
html output

If you want to run the code in the slides in your own RStudio, we recommend downloading a qmd file with the code.
bold, italics, superscripts & subscripts, strikethrough, verbatim, etc.
Text is formatted through a markup language called Markdown (Wikipedia)
Newer versions of RStudio include a Visual editor as well that makes formatting text similar to using a word processor.

Visual editorVisual editor is similar to using a wordprocessor, such as WordMarkdown| Markdown: | Output: |
|---|---|
|
This text is in italics, but so is this text. |
|
Bold also has 2 options |
|
|
|
Needsuper orsub scripts? |
|
Code is often formatted as verbatim |
|
|
# at the beginning of the line to create headersText in editor:

Output:

Important
Make sure there is no space before the #, and there IS a space after the # in order for the header to work properly.

Text in editor:
* This is an **unnumbered list**
+ with *sub-items*
- and *sub-sub-items*,
- or even deeper.
- You can use characters *, +, and - interchangeably to create lists.
* The order of the
* character types is not important
+ and character types can be repeated.
What *is* important is the *spacing*!
+ indent each
* sub-level with a tab and make sure
* there is a __space between the character starting the list and the first bit of text__,
*otherwise the text won't be a new bullet in the list, such as this line.
Also, if you do not have an empty line
+ before starting a list,
+ then the output will be continuous text
- instead of bullet points.What is important is the spacing!
Also, if you do not have an empty line + before starting a list, + then the output will be continuous text - instead of bullet points.
You can also
1. over and over again.
1. or i.
a.,When lists get interrupted
code format.Source editor and examine the markdown code that was used for the formatting.Questions: Share in the chat:
<url>Workshop website link: https://ohsu-octri-berd.github.io/Quarto_BERD_2025/.
[text](url)We also have a shortened bitly link.
[text](url){target="_blank"}This link will open in a new tab bitly link
Add an image with a simple 

You can add html image options to change the width or height:
Specifying width in terms of pixels:
Specifying height in inches:

Specifying width as a percent of the original image size:

Add captions, links, and align

{target="_blank"}]
(/images/ohsu_logo.jpg){width="100" fig-alt="OHSU Logo" fig-align="center"}You can add tabbed content to webpages or slides using the standard Quarto syntax for tabsets. For example:
# vs ## vs ###, etc.) doesn’t matter, but they all have to be the same level to create new tabsets.### level header so that the tabset appears nested within the contents of the slide, which is ## level.Below is the rendered output of the tabset code on the previous slide:
Tip
Callouts are an excellent way to draw attention to specific pieces of information.
Note
They are especially useful for notes, warnings, or tips.
Important
You create them using fenced divs ::: with a special class.
::: {.callout-tip}
## Tip with different title
You can change the title of any
type of callout box by adding
`## New title` right below the
first line of the callout.
:::
::: {.callout-note icon=false}
You can omit the icon of any type
of callout box by adding
`icon=false` within the `{}` of
the first line of the callout.
:::Tip with different title
You can change the title of any type of callout box by adding ## New title right below the first line of the callout.
Note
You can omit the icon of any type of callout box by adding icon=false within the {} of the first line of the callout.
::: {.callout-caution collapse="true"}
## Callouts can be collapsed in
html files (not in slides - yet)
If you look at the html file
(not the slides), you will see
that the content of this callout
is "folded" and needs to be expanded
by the user to see it.
* Use `collapse="true"` if you want it
collapsed by default, and
* `collapse="false"` to make it
expanded by default.
:::Callouts can be collapsed in html files (not in slides - yet)
collapse="true" if you want it collapsed by default, andcollapse="false" to make it expanded by default.Learn more about callout blocks at https://quarto.org/docs/authoring/callouts.html
One benefit of using or switching over to the Visual editor is that it is much easier to add tables.
| Name | Date | Measure |
|---|---|---|
| Jessica | 02/04/25 | 9.3 |
| Meike | 01/03/25 | 10.1 |
| BERD | 🐦 | 10.5 |
Important
Learn more at Quarto Docs: Tables
$ for inline equations: \(y=\beta_0 + \beta_1x + \varepsilon\)* Use double `$$` for centered display equations:
$$\hat{y}= \frac{3}{7} + 5 \textrm{age} + 3^2 \cdot \textrm{height}$$ $$ for centered display equations:\[\hat{y}= \frac{3}{7} + 5 \textrm{age} + 3^2 \cdot \textrm{height}\]
Learn more at Markdown Basics: Equations
.qmd file 
html output 
An empty code chunk looks like this:
Visual editor

Source editor

Important
Note that a code chunks start with ```{r} and ends with ```. Make sure there is no space before ```.
Run Selected Line(s),| Mac | ctrl + return |
| PC | command + return |

Note
3 options to create a code chunk
Click on
at top right of the editor window, or
Keyboard shortcut
| Mac | Command + Option + I |
| PC | Ctrl + Alt + I |
Visual editor: Select Insert -> Executable Cell -> R
Full list of keyboard shortcuts
| action | mac | windows/linux |
|---|---|---|
| Run code in qmd (or script) | cmd + enter | ctrl + enter |
<- |
option + - | alt + - |
| interrupt currently running command | esc | esc |
| keyboard shortcut help | option + shift + k | alt + shift + k |
Practice: Try typing code below in your qmd (with shortcut) and evaluating it (with shortcut):
eval determines whether the R code is run or not.true.false, the code is not run but still displayed in the output:echo determines whether the R code is displayed or not.true. When set to false, the code is not displayed in the output but the output is (if eval is set to true):warning: do you want R’s warnings include in your output?message: do you want R’s messages include in your output?For a complete list of options, see the Quarto reference page for Code Cells: Knitr. In particular the sections on Code Output and Cell Output.
YAML metadataMany output options can be set in the YAML metadata, which is the first set of code in the file starting and ending with ---.
YAML exampleYAML:
Output:

Important
---.--- must be on the very first line.format: option---
title: "Part 2: Quarto Introduction"
pagetitle: "Part 2: Quarto Introduction"
subtitle: "OCTRI-BERD Workshop July 2025"
author: "Jessica Minnier, Meike Niederhausen"
institute: "OHSU-PSU School of Public Health"
date: "7/17/25"
format:
html:
link-external-newwindow: true # open links in a new tab
toc: true # create a table of contents
number-sections: true # numbers header sections
embed-resources: true # IMPORTANT! Creates a standalone html file that other can view without needing additional files.
code-fold: show # true collapses all code chunks; show shows the code
code-tools: true # creates menu at top of html to toggle code folding
execute:
echo: true # show all code in code chunks
eval: true # run all code in code chunks
editor: source # other options is visual
# editor_options:
# chunk_output_type: console # Code output shown in console instead of inline
---