---
title: "Making slide presentations"
author: "Andrew Irwin, a.irwin@dal.ca"
date: "2026-03-17"
format:
  revealjs:
    slide-number: true
    theme:  default
    chalkboard: true
    auto-animate: true
    scrollable: true
    code-block-border-left: true
    code-copy: false
    code-link: true
    history: false
    width: 1200 # default 1050
    height: 700
    margin: 0.05  # default 0.1
    min-scale: 0.2
    max-scale: 2.0
    fig-cap-location: top
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
my_theme = theme_bw() + 
  theme(text = element_text(size=18))
```


```{r include=FALSE}
library(tidyverse)
library(kableExtra)
```

# Goals

- Why do we make slides?
- Introduction to the most important tools for making slides with R

## What are slides for?

- An aid to oral communication
  * Usually a small amount of text and a "display item" (figure, table, equation, code)
  * Designed to help you communicate a specific point
- Visualizations on slides differ from reports
  * Large text, bold colours, material tailored to presentation

## Create a template


Rstudio menu: 

* File
  * New File...
    * Quarto presentation
      * Check "RevealJS"

## Documentation

* Quarto format: like regular R markdown documents, with a few variations
  * [Quarto documentation](https://quarto.org/docs/presentations/)
  * [Full list of options](https://quarto.org/docs/reference/formats/presentations/revealjs.html) and [RevealJS documentation](https://revealjs.com/)

* [Demo](https://quarto.org/docs/presentations/revealjs/demo/#/title-slide) slides and [code](https://github.com/quarto-dev/quarto-web/blob/main/docs/presentations/revealjs/demo/index.qmd) for demo slides
  
## Essentials

Like R markdown, but use two hashes (`##`) to start a slide and make a title at the top.


A heading with single hash mark makes a vertically-centred title

Use three minus signs (`---`) to start a new slide with no title.

## Stopping distance increases with car speed

```{r}
#| echo: false
#| fig-width: 6.5
#| fig-height: 4
#| fig.align: center
cars |> ggplot(aes(speed, dist)) + geom_point(size=4) +
  geom_smooth() + 
    theme_bw() + 
  theme(text=element_text(size=24)) +
  labs(x = "Speed (miles/h)",
       y = "Stopping distance (ft)")
```


## Show computer code

Use `echo=TRUE`.

```{r eval=TRUE, echo=TRUE}
cars |> ggplot(aes(speed, dist)) + geom_point()
```

## Formatting text and adding images

All markdown formatting for *italics*, **bold**, [hyperlinks](https://www.r-project.org/) are available.

You can include images.

![A kitten](kitten.jpeg)

## Two column format

:::: {.columns}
::: {.column width="50%"}
```{r eval=FALSE}
mpg |> count(class)
```

```{r echo=FALSE}
mpg |> count(class) |> kable() |> kable_styling()
```
:::
::: {.column width="50%"}
```{r echo=FALSE}
#| label: demo-figure
#| fig-cap: "The number of observations tabulated by class of car."
mpg |> count(class) |> ggplot(aes(x = class, y = n)) + geom_col() + 
  theme_bw() + theme(text=element_text(size=30)) +
  theme(axis.text.x = element_text(angle=90))
```
:::
::::


## Summary

* I've shown a simple set of slides you can easily make using Rstudio and Quarto/RevealJS (very similar to R markdown)

* Your slides should use large text and images

* Use formatting (see lesson on [reproducible reports](20-reproducible-reports.qmd)) to control how code and visualizations are displayed

* [A link to the full code for these slides](https://raw.githubusercontent.com/AndrewIrwin/data-viz-course/main/data-viz/slides/24-slide-presentation.qmd) 

