[1] 4016
``` **{r} or {python} **#|** not needed in a code cell in a Jupyter notebook!
Useful code chunk options:
#| eval: true: Evaluates code chunk.#| echo: true: Includes source code in output.#| output: true: Includes results of code execution in output.#| warning: true: Includes warnings in output.#| include: false: Catch all for preventing anything from being included.#| label: something-meaningful: Good practice to always include!Options for figure-creating code chunks:
#| fig-cap: "your figure's caption" : caption of the figure#| fig-width: 8 : width of the figure#| fig-height: 6 : height of the figureOptions for all code chunks: include in yaml (top of the document).
Option 1: Type it out
Option 2: Visual editor: Insert > Code cell
Option 3: Shortcuts:
Go to the Code Chunks chapter in the workshop book and 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?
In R
In Python (Quarto >= 1.4)
In Jupyter notebooks: also add this to the document yaml:
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 one of them to include the code in your Quarto document.
Go to the Sourcing code chapter in the workshop book and complete the exercise!
10:00
Other options not discussed here: