[1] 3
2024-09-09
Start a new empty document.
At the top you see:
The things between the ---
is the YAML header.
You will see it used throughout the Quarto guide.
*italics*
or _italics_
= italics
**bold**
= bold
***bold italics***
= bold italics
~~strikethrough~~
= strikethrough
`code`
= code
This:
```
line 1
line 2
```
shows code chunks:
line 1
line 2
You can start sections and subsections like this:
# Header 1
## Header 2
### Header 3
Show the link and add link: <https://quarto.org/docs/guide/>
Add link to text: [Quarto Guide](https://quarto.org/docs/guide/)
Looks like this:
![My caption](https://datasciencedojo.com/wp-content/uploads/11-1.jpg)
Shows the plot and caption:
My caption
The image can also be a local file.
Bullets:
- bullet 1
- sub-bullet 1
- sub-bullet 2
- bullet 2
Looks like this:
Ordered list:
1. Item 1
2. Item 2
Looks like this:
Note
If you are going to write technical report, you definitely want to learn LaTeX.
Once you learn LaTeX you will never want to use an equation editor again.
There are many online tutorials, like this one.
ChatGPT is great at LaTeX
Examples:
Inline: $Y_i = \beta_0 + \beta_1 x_i + \varepsilon_i$
looks like this \(Y_i = \beta_0 + \beta_1 x_i + \varepsilon_i\)
Display math:
$$
\mathbf{Y} = \mathbf{X\beta} + \mathbf{\varepsilon}
$$
looks like this:
\[ \mathbf{Y} = \mathbf{X\beta} + \mathbf{\varepsilon} \]
The main reason we use Quarto is because we can include code and execute the code when compiling the document.
In R we refer to them as R chunks.
This applies to plots as well; the plot will be placed in that position.
Note
To add your own R chunks, you can type the characters above quickly with the key binding command-option-I on the Mac and Ctrl-Alt-I on Windows.
We can write something like this:
It look slike this:
Note that it was evaluated and the result is shown.
By default, the code and result will show up as well.
You can send arguments to control the behavior with |#
For example, to avoid showing code in the final document, you can use the argument echo: FALSE
.
There are many options (auto-complete shows them).
For example, to avoid the the code running you can use eval: FALSE
.
To avoid showing warnings warning: FALSE
, to avoid showing messages message: FALSE
.
Helps with debugging
Gives meaningful names to generated images.
There is a lot more you can do with R markdown. We highly recommend you continue learning as you gain more experience writing reports in R. There are many free resources on the internet including:
RStudio provides the Render button that makes it easier to compile the document.
You can also type quarto render filename.qmd
on the command line. This offers many options.
You can produce html, pdf, or word documents.
You can specify the default in the YAML header using: format: html
, format: pdf
,format: docx
, or format: gfm
(gfm stands for GitHub flavored markdown, a convenient way to share your reports).