---
pagetitle: "RevealJS"
title: '`r paste0(params$name," presentation")`'
subtitle: "Parameterized presentation"
author: "Roy Francis"
date: last-modified
format: revealjs
params:
  name: setosa
---

## Packages {visibility="hidden"}

```{r}
library(ggplot2)
```

```{r}
#| echo: false
#| output: asis
cat("## ",params$name)
```

The `r params$name` species is subsetted from the data.

```{r}
iris_filtered <- subset(iris, iris$Species == params$name)
```

```{r}
head(iris_filtered)
```

::: aside
The iris dataset is included in base R.
:::

## Layout

This slide shows a two column layout.

:::: {.columns}
::: {.column width="50%"}

```{r}
#| label: fig-scatterplot
#| fig-cap: !expr paste0("Scatterplot of ",params$name," species.")
ggplot(iris_filtered,aes(Sepal.Length,Petal.Length,col=Species))+
    geom_point()+
    labs(title=params$name)
```

:::

::: {.column width="50%"}

```{r}
#| echo: false
#| label: fig-species
#| fig-cap: !expr paste0("Photograph of ",params$name," species.")

imgs <- c(
    "setosa" = "assets/setosa.jpg",
    "versicolor" = "assets/versicolor.jpg",
    "virginica" = "assets/virginica.jpg"
)

knitr::include_graphics(imgs[match(params$name, names(imgs))])
```

:::
::::

## Code highlighting

```{r}
#| echo: true
#| label: fig-scatterplot-size
#| fig-cap: !expr paste0("Scatterplot of ",params$name," species.")
#| code-line-numbers: "2"
ggplot(iris_filtered,aes(Sepal.Length,Petal.Length))+
    geom_point(aes(size=Petal.Width))+
    labs(title=params$name)
```

::: {.notes}
The figure is updated to show petal widths.
:::
