---
title: "Title"
author: "Author"
date: "04/08/2026"
output: ioslides_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## Overview

While there are others, I recommend using one of the three following presentation formats. (Note: You can change the format in the `output` parameter in the header of the `.rmd` file.)

-   `beamer_presentation` for making .pdf slides (using a .tex engine)
-   `ioslides_presentation` for making .html files
-   `slidy_presentation` for making .html files

## Syntax

The syntax for R Markdown slides is similar to creating R Markdown documents (like problem sets).

We can write sentences using **bold face**, *italics*, using [links](http://ppol_6803.alexanderpodkul.com) or also make equations like

$$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$

We can also (Note: replace with - for unnumbered):

1.  write
2.  numbered
3.  lists

## Syntax (Continued)

We can also continue to write code.

```{r, echo=T}
example_code <- 'This will be printed'
```

```{r, echo = F}
example_code2 <- 'This will not be printed'
```

Remember, in the header to the code chunk:

-   `echo` - TRUE/FALSE - will print the code in our output
-   `eval` - TRUE/FALSE - will *evaluate* the code chunk
-   `warning` - TRUE/FALSE - will print any warnings that the code produces
-   `message` - TRUE/FALSE - will print any messages that the code produces

(or set globally in line 9)

## Creating New Slides

The only major difference is that `## Title` creates a new slide in our deck(!)

## Adding Visualizations

```{r, echo = F, eval=T, fig.align='center', out.height='90%', out.width='90%'}
library(ggplot2)
library(ggthemes)
data <- data.frame(x = 1:500, 
                   y = rnorm(n = 500, mean = 10, sd = 30)
                   )

ggplot(data) + 
  geom_density(aes(x = y)) + 
  theme_igray()

```

## Adding Tables (1 of 2)

```{r, echo = F, eval = T, message= F}
library(dplyr)
library(kableExtra)

data <- data.frame(x = 1:500, 
                   y = rnorm(n = 500, mean = 10, sd = 30)
)

data %>% 
  dplyr::summarize(`Mean of X` = mean(x), 
            `Median of Y` = median(y), 
            `Number of Observations` = n()) %>%
  kbl() %>%
  kable_minimal()

#Tables in pdf: https://cran.r-project.org/web/packages/kableExtra/vignettes/awesome_table_in_pdf.pdf
#Tables in html: https://cran.r-project.org/web/packages/kableExtra/vignettes/awesome_table_in_html.html
```

## Adding Tables (2 of 2)

```{r, echo = F, eval = T, message= F}
library(dplyr)
library(kableExtra)
library(broom)

lm(y~x, data = data) %>%
  tidy() %>%
  kbl() %>%
  kable_material_dark()

```

## Common Pitfalls and Advice

**Common Pitfalls**

-   Having stray spaces (in slide names or in lists)
-   Re-running timely models every time you "knit"
-   Forgetting to start a new slide

**Advice**

-   When starting out, **Knit** after each slide is done (to isolate errors)
-   Only include the data and code that you need
-   Run code chunk by chunk to isolate errors

## Resources

Useful documentation:

-   [R Markdown Cheat Sheet](https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf)
-   [ioslides Documentation](https://bookdown.org/yihui/rmarkdown/ioslides-presentation.html)
-   [Slidy Documentation](https://bookdown.org/yihui/rmarkdown/slidy-presentation.html)
-   [beamer Documentation](https://bookdown.org/yihui/rmarkdown/beamer-presentation.html)

Additional customization:

-   [Using beamer](https://bookdown.org/yihui/rmarkdown/beamer-presentation.html#themes)
-   [Using Slidy](https://garrettgman.github.io/rmarkdown/slidy_presentation_format.html#appearance_and_style)
-   [Using ioslides](https://bookdown.org/yihui/rmarkdown/ioslides-presentation.html#custom-templates-2)
