+ - 0:00:00
Notes for current slide
Notes for next slide

ICO Workshop R & RStudio

Part 2

Markdown & Quarto

Sven De Maeyer & Tine van Daal

2nd - 4th July, 2024

1 / 35

Overview

2 / 35

1. What is markdown?

3 / 35

Markdown

  • 'low end' text editor system

  • make content that can be read on different systems

  • mainly easy way to generate html files

  • you write in 'plain text' and an interpreter generates an nice edited version

4 / 35

Basic syntax

5 / 35

Extension

extended lijst van commando's

extended lijst van commando's

6 / 35

2. Integrating Markdown and R code

7 / 35

Rmarkdown & Quarto

Two roads with the same destination, but...

Rmarkdown

  • developed 10 years ago by RStudio company
  • an R package
  • only works in RStudio
  • still supported but no major advances in development
  • generates pdf, html and word-docs

Quarto

  • recently developed by RStudio company
  • stand alone software
  • integrates with RStudio but also with other software
  • cross-language platform (python, Julia, Observable, ...)
  • all new cool new stuff will be implemented in Quarto
  • generates pdf, html, word, open-office, ppt, ePub, Observable JS, Jira Wiki, websites, online books, etc
  • CEO of RStudio company anounced the development of an online editing application (like google docs)
8 / 35

How Quarto works...

9 / 35

Quarto info

If you want to learn more about Quarto, a lot of information is available at

https://quarto.org/docs/guide/


AND


there are great extensions!

see: https://quarto.org/docs/extensions/

10 / 35

Installing Quarto

Click on GET STARTED

11 / 35

Installing Quarto

Choose the correct version for your pc

Install the software and restart RStudio

12 / 35

Check the installation

You should see the option to open a new "Quarto document" in RStudio

13 / 35

3. Creating a basic Quarto document

14 / 35

A first basic hands-on exploration of Quarto

Let's create a first Quarto Document...


The following slides are some screen shots of what we all did together, hands-on 😊

15 / 35

Open a New File

  • Click on File
  • Choose New File
  • Choose Quarto Document...

Result:

16 / 35

Fill in some basic info

  • Fill in a title and an author
  • Click on Create

Result:

17 / 35

Two different views

Source editor

= raw 'markdown' language

Visual editor

= like a worddoc editor (see what you get)

18 / 35

Two parts of a Quarto document

YAML

To set some of the parameters (aka Metadata)

Your narrative:

Titles +

text +

code +

output +

tables +

figures (generated by code) +

images +

(exeternal and internal) links +

references +

embeded content (e.g., YouTube Video)

etc.

19 / 35

Code chunks

All R-code can be written in Code chunks

While constructing your Quarto document you can RUN code chunks

Click the green arrow (top-right corner of code chunk)

As a result you get the output printed in your Quarto document

20 / 35

Code chunks

ATTENTION!: The order of code chunks do matter. If you want to run all the code in the code chunks before a certain code chunk, you can click on the button aside of the green arrow (downward green arrow)

21 / 35

Adding a new code chunk










Or with a short-cut (on your keyboard)...

Windows: ctrl + alt + i

Mac: option + command + i

22 / 35

Code chunk options

  • #| include: false /rightarrow code and output (result) are hidden but code is executed

  • #| echo: false: only results are printed, code is hidden

  • #| message: false hides messages coming from R related to running the code

  • #| warning: false hides warnings coming from running the code

  • #| error: false hides error messages coming rom running the code

  • #| fig.cap = "..." adds a caption for a figure created

More detailed information: https://yihui.org/knitr/options/

23 / 35

Inserting references

You can easily insert citations and references

24 / 35

Inserting references

If you work with Zotero there is an easy integration! (https://www.zotero.org/)

Search references based on DOI

Easy to find and insert citations of R packages installed on your computer

25 / 35

Inserting a callout

To highlight some specific piece of text you can use a callout

It will generate something like this in your final html document:

26 / 35

Inserting a callout

27 / 35

Adding a Tabset

In an html file you can also add Tabsets... They look like this in the resulting html file:

This is a way to save space on the canvas and keep your file tight and neat.

28 / 35

Adding a Tabset

Go to Insert and choose Tabset

29 / 35

Adding a Tabset

This opens the following menu:

You can fill in the titles for each tab in the Tabset:

30 / 35

Adding a Tabset

In the Quarto document you now have a section to make content for each tab in the Tabset:

31 / 35

Changing your theme

If you don't like the formatting of the rendered html file, there are some other themes that can be used!

See: https://quarto.org/docs/output-formats/html-themes.html

This is something you can tweak in the YAML of the file

For instance, let's choose the formatting according to the journal theme

32 / 35

Changing your theme

Let's try another one: superhero!

This one is clearly different from the default theme.

Of course, if you feel adventurous you can build your own theme (e.g., to meet the branding of your university)

33 / 35

Tweaking your theme in the YAML

Some elements of formatting can be easily added in the YAML

See https://quarto.org/docs/output-formats/html-basics.html

For instance, let's also add a table of contents (toc) that contains all headers up till level 3

34 / 35

Code folding

By default all the code is shown for code chunks that have not set the option #| echo: false

This behaviour can be changed in the YAML by introducing the code-fold: true option

35 / 35

Overview

2 / 35
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow