[1] 4016
```
**{r}
or {python}
**#|
** not needed in a code cell in a Jupyter notebook!
Options for all code chunks: include in yaml
(top of the document).
Option 1: Source editor: Type it out
Option 2: Visual editor: Insert
> Code cell
Option 3: Shortcuts:
echo
hides/shows code
eval
creates results
eval
shows code, but does not create results.
Go to the analysis section on the website do the exercise.
You will be pasting some code from a dummy
script into code chunks in your document!
15:00
Insert results or (quick) calculations into running text, without additional text formatting.
Why?
Enclose the R expression using `r `
.
Code:
There are `r nrow(cars)` observations in our data.
Output:
There are 50 observations in our data.
Important
If using Visual
or Source
mode, be advised the R expression will only substitute the value held by the variable when the Quarto document is rendered. That is, the value contained within the expression only appears in the output file.
Code:
The _mean_ of **x** is `r x_mu` and
the _standard deviation_ is `r x_sd`.
Output:
The mean of x is 5.5 and the standard deviation is 3.02765.
In R
Take a couple of minutes to play around with the possibilities of inline code!
Go to the Inline code chapter in the workshop book to complete the exercise.
10:00
For example: R and Python scripts, .qmd
or .ipynb
files.
Why separate scripts from the manuscript?
.qmd
files: use the chunk option #| file: "your-script.ext"
.
.ipynb files
: import the script as module or run it.
The workshop-materials
contain 2 example scripts: do_addition.R
and do_addition.py
. You will use the R script to include the code in your Quarto document.
10:00