05:00
Content
- Text
- Links
- Images
- Code
- Embedded tables and plots
- Equations
- References
Then click the Render button.
Rhian Davies & Nicola Rennie
Go to the welcome page quarto.jumpingrivers.training/welcome/
Enter your e-mail address and password papaya-guava
Make a note of your username and password
Log in at quarto.jumpingrivers.training
We’ll get started when the countdown finishes.
05:00
Quarto let’s us write documents that combine code with text. It works for multiple languages and multiple output formats. Let’s explore the Quarto gallery.
R Markdown isn’t going anywhere but…
File > New File > Quarto Document
Set title and author
Click Create
Save and click Render
Then click the Render button.
Check out the Quarto documentation.
There are different ways to add images to a Quarto document. The easiest way is to use the Visual editor - click Insert –> Figure/Image
File > New File > Quarto Document
Set title and author
Click Create
Save and click Render
Add the text from task1.txt
Add a link to the Duke Lemur Center https://lemur.duke.edu/
Add an image of the Mongoose Lemur
15:00
… and lemurs…
You can load in your data:
We can also load in some R packages. But maybe, we collapse the code…
… do some data wrangling, and print the output as a table…
name | weight_g | sex | age_at_wt_mo |
---|---|---|---|
NICOLE | 2170.0 | F | 31.33 |
ALAIN | 2502.0 | M | 22.98 |
ALAIN | 1637.5 | M | 30.58 |
ALAIN | 2243.0 | M | 37.22 |
GASTON | 1916.0 | M | 37.87 |
GASTON | 2147.5 | M | 38.30 |
…or include some exploratory plots!
```{r}
#| label: plots
#| message: false
#| output-location: slide
#| code-overflow: wrap
#| fig-cap: "Age vs weight of Young Adult Collared Brown Lemurs"
#| fig-alt: "Plot of age vs weight of young adult collared brown lemurs, split by male and female showing positive relationship for both"
ggplot(data = df,
mapping = aes(x = age_at_wt_mo,
y = weight_g,
colour = sex)) +
geom_point() +
geom_smooth(method = "lm") +
labs(title = "Young Adult Collared Brown Lemurs",
x = "Age (months)",
y = "Weight (g)") +
theme_minimal()
```
We can also include code inline, rather than as a separate chunk.
The largest lemur recorded is called `r str_to_title(big_lemur$name)`
, who weighed `r format(big_lemur$weight_g, scientific = FALSE)`
grams.
The largest lemur recorded is called Sabina, who weighed 10337 grams.
Try to render the document, what are the problems?
Add a new code chunk to load the libraries {ggplot2}, {dplyr} and {tidyr}
Set the code chunk options for your new chunk to the hide the code and messages
Add a caption to the plot with the fig-cap
code chunk option
Add a code chunk to fit a linear model fit = lm(weight_g ~ age_at_wt_mo, data = df)
Use inline code chunks to give the model fit coefficients in the sentence. Hint: fit$coefficients
15:00
We can use LaTeX to add equations.
\[\begin{equation} \hat{e}_i = Y_i - \hat{Y}_i \end{equation}\]
Correctly formatted journal articles in 30 seconds?
Try quarto-journals e.g. for a Journal of Statistical Software article:
Create a reference file:
@article{Andriambeloson2020,
title={Prolonged torpor in Goodman’s mouse lemurs (Microcebus lehilahytsara) from the high-altitude forest of Tsinjoarivo, central-eastern Madagascar.},
author={Andriambeloson JB, Greene LK, Blanco MB},
journal={Folia Primatologica},
volume={91},
pages={697–710},
year={2020}
}
Add a link to your reference file in your .qmd document YAML:
Then link the reference using an @.
To cite a paper about lemurs [@Andriambeloson2020]
Open task-3.qmd
Add the equation for linear regression y = mx + c
in
Link to the reference.bib
file in your .qmd
document YAML header
Fix the reference link using an @
.
15:00
Quarto docs: quarto.org
RStudio Workshop: jthomasmock.github.io/quarto-2hr-webinar
Our training courses