+ - 0:00:00
Notes for current slide
Notes for next slide

36-315: Statistical Graphics and Visualization

Lecture 14

Meghan Hall
Department of Statistics & Data Science
Carnegie Mellon University
June 25, 2021

1

Today


Presentations with xaringan
making slides with .Rmd


Tips for the final report
what needs to be included
how to get a great grade

2

Final report: what to include

An overview of the data
what's included, what's not included, what's missing
at the appropriate level of detail

3

Final report: what to include

An overview of the data
what's included, what's not included, what's missing
at the appropriate level of detail


Your questions
plots and summaries
be thorough! a very short summary will not suffice
describe the conclusion, not the graph

3

Final report: what to include

An overview of the data
what's included, what's not included, what's missing
at the appropriate level of detail


Your questions
plots and summaries
be thorough! a very short summary will not suffice
describe the conclusion, not the graph


Conclusions
limitations & ideas for future work
what other data do you think could be useful?

3

Final report: tips to make it great

Take care with your plots
consistent colors, plot themes, customize beyond the standard, etc.
if plots go together, use cowplot!

4

Final report: tips to make it great

Take care with your plots
consistent colors, plot themes, customize beyond the standard, etc.
if plots go together, use cowplot!


Show what you've learned in the class
use plots appropriately
use a variety of plot types (and tables!)

4

Final report: tips to make it great

Take care with your plots
consistent colors, plot themes, customize beyond the standard, etc.
if plots go together, use cowplot!


Show what you've learned in the class
use plots appropriately
use a variety of plot types (and tables!)


Leave the .html output code-free
edit your setup chunk to echo = FALSE

4

Tips for the presentation

Each team member needs to speak

5

Tips for the presentation

Each team member needs to speak


Introduce the data set, briefly cover each question
probably not time to discuss each plot

5

Tips for the presentation

Each team member needs to speak


Introduce the data set, briefly cover each question
probably not time to discuss each plot


Touch on limitations & ideas for further work
what other data would you like access to?

5

Tips for the presentation

Each team member needs to speak


Introduce the data set, briefly cover each question
probably not time to discuss each plot


Touch on limitations & ideas for further work
what other data would you like access to?


My recommendation: practice but don't memorize

5

xaringan

Presentations with R Markdown
.html output
easy to incorporate plots & code
other options: ioslides, Slidy, Beamer


Pros:
easy to customize
looks great


Cons:
hard to share without hosting it somewhere
easiest with a web connection

6

xaringan


Get started:
install the xaringan package
File > New File > R Markdown > From Template > Ninja Presentation
template file has lots of examples


Chapter 7 of R Markdown: The Definitive Guide

7

xaringan basics


Slide formatting made possible by Markdown
headings, bullet points, etc.
can add links & images

8

Basic markdown

*Hello* my name is **Meghan**
- This
- makes
- bullet points

Hello my name is Meghan

  • This
  • makes
  • bullet points
9

Headings

# This is a slide heading
## This is a smaller heading
### This is yet a smaller heading

This is a slide heading

This is a smaller heading

This is yet a smaller heading

10

Links & images

The course website is linked [here](http://cmu-36315.netlify.app/)
.center[![logo](figs/Lec2/penguins.png)]
.right[*Art by Allison Horst*]

The course website is linked here

logo

Art by Allison Horst

11

xaringan basics


Slide formatting made possible by Markdown
headings, bullet points, etc.
can add links & images


Can add code & plots with chunk options
all thanks to knitr


Resources:
R Markdown reference guide
R Markdown cookbook
chunk option details

12

Code

```{r penguins-1, eval = FALSE}
penguins %>%
count(species) %>%
ggplot(aes(x = reorder(species, -n), y = n, fill = species)) +
geom_bar(stat = "identity", show.legend = FALSE) +
scale_fill_viridis_d(option = "E") +
labs(x = NULL, y = NULL) +
theme_linedraw()
```
penguins %>%
count(species) %>%
ggplot(aes(x = reorder(species, -n), y = n, fill = species)) +
geom_bar(stat = "identity", show.legend = FALSE) +
scale_fill_viridis_d(option = "E") +
labs(x = NULL, y = NULL) +
theme_linedraw()
13

Plots

```{r penguins-2, echo = FALSE, fig.height = 5, fig.align = "center"}
penguins %>%
count(species) %>%
ggplot(aes(x = reorder(species, -n), y = n, fill = species)) +
geom_bar(stat = "identity", show.legend = FALSE) +
scale_fill_viridis_d(option = "E") +
labs(x = NULL, y = NULL) +
theme_linedraw()
```

14

Tables

### .center[the `penguins` data set]
```{r kable-1, echo = FALSE}
penguins %>%
count(species) %>%
kable("html") %>%
kable_styling(font_size = 16, position = "center", full_width = F) %>%
row_spec(0, bold = T, color = "white", background = "#bb0000")
```

the penguins data set

species n
Adelie 152
Chinstrap 68
Gentoo 124
15

YAML

---
title: "Our Sample Presentation"
subtitle: "for learning xaringan"
author: "Meghan Hall"
institute: "Carnegie Mellon University"
date: "2021-06-25"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
16

Your setup chunk

Similar to that in other .Rmd documents
load packages, add themes
can set global chunk options

```{r setup, include = FALSE}
library(kableExtra)
library(tidyverse)
library(palmerpenguins)
options(knitr.kable.NA = '')
options(htmltools.dir.version = FALSE, htmltools.preserve.raw = FALSE)
knitr::opts_chunk$set(fig.retina = 3,
warning = FALSE,
message = FALSE,
fig.path = "figs/Lec14/")
```
17

Customizing xaringan


Some built-in themes
list here: https://github.com/yihui/xaringan/wiki/Themes


xaringanthemer
can easily create a custom color palette based on one color


Or add even more css if you prefer!
not at all required

18

Upcoming


Lecture 15 Monday
interactive options
also: presentation sign-ups


Homework 5 due Tuesday


Lab 10 on Tuesday

19

To RStudio!

20

Today


Presentations with xaringan
making slides with .Rmd


Tips for the final report
what needs to be included
how to get a great grade

2
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow