---
title: "Tables and figures"
format: html
editor: source
---

```{r}
#| label: load-packages
#| message: false

library(tidyverse)
library(ggthemes)
library(palmerpenguins)
```

## Task 1: Cross-reference an image

1.  Include the Quarto logo from the `images/` folder as a figure. Add a caption, id, and cross-reference to the figure. Tips: <https://quarto-ambition.github.io/website/1-2-documents/1-2-documents.html#/figure-cross-references>

## Task 2: Cross-reference a table from code

1.  Render the document and identify if the cross-reference to the table generated from the code below works.

2.  Fix the label in the code-chunk below so that the cross-reference works.

3.  Render the document to check if the cross-reference to the table generated from the code below works

See @tbl-penguins for data on a few penguins.

```{r}
#| label: penguins
#| tbl-cap: Bill depth of penquins by island and species.

penguins |> 
  filter(!is.na(bill_depth_mm)) |> 
  group_by(island, species) |>
  summarise(n = n(),
            mean_bill_depth = mean(bill_depth_mm),
            sd_bill_depth = sd(bill_depth_mm)) |>
  ungroup() |> 
  gt() |> 
  fmt_number(columns = c(mean_bill_depth, sd_bill_depth),
             decimals = 1)
```

## Task 3: Cross-reference a figure generated from

1.  Add a caption and a label for a figure to the code chunk options below.
2.  Add a cross-reference to the figure generated from the code below.

In ...

```{r}
#| warning: false

ggplot(data = penguins,
       mapping = aes(x = bill_length_mm, 
                     y = bill_depth_mm,
                     color = species,
                     shape = species)) +
  geom_point() +
  scale_color_colorblind() +
  labs(x = "Bill length (mm)", y = "Bill depth (mm)") +
  theme_minimal()
```
