1+1[1] 2
You can include various code blocks. We’ll demonstrate with R code initially.
You can include inline code.
This sentence ends with a number created by inline code, 1+1 = 2.
The above sentence in markdown code:
Code block and output:
Code block markdown code:
To show the code block but not the output add the option eval=FALSE
Code block markdown code:
To show only the output but not the code block add the option echo=FALSE
[1] 1200
Code block markdown code:
Libraries need to be loaded for each page you want to use them.
You can add the below code block at the top of your markdown page to silently load the Tidyverse package. Otherwise your markdown file will have all the unneeded output from loading a library.
You can include bash and python code.
Python code:
Markdown code:
More information include installation instructions here: Quarto Using Python
Linux code:
If your page has no R code and uses non-R languages you will need the below code at the top of each .qmd page that contains non R code. This will mean you will still produce .html pages. You need this even if you set eval=FALSE.
You can display the markdown code for a code block.
Code block:
Markdown code for code block:
Markdown code for code block’s markdown code: