Using Quarto for your analyses ensures that your code, results, and documentation are integrated into a single document, enhancing reproducibility and transparency.
Before starting to use quarto you can test where you want the output to appear when you print a data frame or a plot. as a standard it appears inline after each code chunk. But in the settings its possible to change it to appear in the console and the plot pane.
Quarto is an open-source scientific and technical publishing system that allows you to create dynamic documents, presentations, websites, and more. It’s similar to R Markdown but offers additional features and flexibility.
5.1 Structure of a Quarto Document
A Quarto document typically consists of three main parts:
YAML Header: Contains metadata about the document.
Markdown Content: Text, code chunks, and other content written in Markdown.
Code Chunks: Embedded code for dynamic content.
5.1.1 1. YAML Header
The YAML header is placed at the top of the document, enclosed by --- lines. It includes metadata such as the title, author, date, and output format.
---title:"Introduction to Quarto"author:"Dr. [Your Name]"date:"2024-06-12"format: html---
If wanting a self-contained Quarto document, i.e., a file that can be mailed to someone else for instance, then you should ensure all dependencies and resources (such as images, data files, etc.) are either embedded within the document or included in a way that they can be accessed by the recipient. Here’s how to achieve this:
---title:"Self-Contained Quarto Document"author:"Dr. [Your Name]"date:"2024-06-12"format:html:self-contained:true---
Embedding Resources
1. Embedding Images: Convert images to base64 encoding and embed them directly into the document.
5.1.2 2. Markdown Content
Markdown is a lightweight markup language for creating formatted text using a plain-text editor. In a Quarto document, you write your content in Markdown. For example:
6 Introduction
This is an introduction to Quarto documents. You can include headings, paragraphs, lists, and other Markdown elements.
6.1 Example
Here is an example of a list:
Item 1
Item 2
Item 3
6.1.1 3. Code Chunks
Code chunks allow you to embed R, Python, or other code within your document. They are enclosed by triple backticks and specify the language after the first set of backticks.
R Code Chunk
# R code examplesummary(cars)
speed dist
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00