Example slidify

Subtitle goes here

Joseph Casillas
PhD Candidate

Slidify

  • In this tutorial I am going to show you how to make a presentation just like this one
  • I will also show some of the features that can be used in conjunction with slidify (i.e. quizzes and html widgets)
  • You can download the current version of this presentation here, use it as a template and edit as you like
  • Or you can follow these instructions to make one of your own

First things first...

Install packages

  • Slidify works in R, so you need to download that if you haven't yet.
  • You also need to make sure you have all of the necessary dependencies installed on your computer
  • Open R and copy and paste the following code into the console (you only need to do this once)
install.packages("devtools")  
install_github('slidify', 'ramnathv')  
install_github('slidifyLibraries', 'ramnathv')

Create slidify

  • Each presentation is called a 'deck'
  • Set your working directory to wherever you want the folder (setwd("path/here"))
  • Load the slidify package with library(slidify)
  • Create the deck with author('mydeck')
    • You can name it whatever you want
    • This will create a folder with all the necessary files

Explore the deck

  • You should now have a folder in your working directory with the name you entered above
  • All of the necessary files are there
  • The .Rmd file is the only one you need to work with
    • This is where you will actually modify the deck (your presentation)
    • It should have opened automatically if you are using RStudio
  • The YAML front matter (the very first thing in the .Rmd file) should look like this...
---  
title       :  
subtitle    :  
author      :  
job         :  
framework   : io2012        # {io2012, html5slides, shower, dzslides, ...}  
highlighter : highlight.js  # {highlight.js, prettify, highlight}  
hitheme     : tomorrow      #   
widgets     : []            # {mathjax, quiz, bootstrap}  
mode        : selfcontained # {standalone, draft}  
knit        : slidify::knit2slides  
---  
  • You can fill in the information as you see fit
    • You will typically use title, subtitle, author, job
    • but the widgets are also important
---
title       : Example slidify
subtitle    : Subtitle goes here
author      : Joseph Casillas
job         : PhD Candidate
framework   : io2012        # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js  # {highlight.js, prettify, highlight}
hitheme     : tomorrow      # 
widgets     : [mathjax, quiz, bootstrap] # {mathjax, quiz, bootstrap}
mode        : selfcontained # {standalone, draft}
knit        : slidify::knit2slides
logo        : ua.png
biglogo     : ua.png
assets      : {assets: ../../assets}
---
  • You can make your deck look like this
  • Specifically, you should add widgets : [mathjax, quiz, bootstrap]

Widgets

  • The widgets will allow you to...
    • make quizzes
    • use math formulas and
    • utilize the bootstrap framework
  • The logos are located in the assets > img folder
    • This is where you will add any other images you want to put in your presentation

RMarkdown syntax

  • Markdown syntax is very easy
  • You can find the basics here
  • The main thing you need to know is that you make new slides using --- and ##

##

  • The double pound sign (hashtags) create the title of the slide
  • The title of this slide was made with ## Rmarkdown syntax

---

  • To end a slide use three dashes
  • Importantly after you end a slide, you designate the class of the next one
  • The default (what you see here) is .class #id
  • So I ended this slide using --- .class #id
## RMarkdown syntax

- Markdown syntax is very easy
- You can find the basics [here](http://rmarkdown.rstudio.com)
- The main thing you need to know is that you make new slides using `---` and `##`

### `##`

- The double pound sign (hashtags) create the title of the slide
- The title of this slide was made with `## Rmarkdown syntax`

### `---`

- To end a slide use three dashes
- Importantly after you end a slide, you designate the style of the next one 
- The default (what you see here) is `.class #id`
- So I ended this slide using `--- .class #id`

 --- .class #id
  • This is the previous slide in markdown

Creating the deck

  • Once you have made the slides in markdown you are ready to generate the html file that will be your presentation
  • You do this using the slidify() command like this...
slidify('index.Rmd')
  • This will generate a index.html file.
  • Double click it and open your presentation in web browser

Incorporating r code

R code

  • You can insert code by surrounding it with ```{r}, followed by ``` (three more ticks)...

```{r}
code here
```

  • Here is an example of some simple math
2 + 2
## [1] 4
  • To do this I typed

```{r}
2 + 2
```

R code (cont)

  • Here is another example
plot(cars)
abline(lm(dist ~ speed, data = cars), col = "red")

plot of chunk unnamed-chunk-4

R code (cont)

  • Here is a more complex example
library(ggplot2)
g <- ggplot(cars, aes(speed, dist))
g + geom_point() +
    geom_smooth()

plot of chunk unnamed-chunk-5

Quizzes

Radio

Eleanor scores 680 on the Mathematics part of the SAT. The distribution of SAT scores in a reference population is Normal, with mean 500 and standard deviation 100. Gerald takes the American College Testing (ACT) Mathematics test and scores 27. ACT scores are Normally distributed with mean 18 and standard deviation 6. Assuming that both tests measure the same kind of ability, who did better?

  1. Eleanor
  2. Gerald

The best way to compare their performance is to calculate their standardized scores.

\[z_E = \frac{680 - 500}{100} = 1.8\] \[z_G = \frac{27 - 18}{6} = 1.5\]

Since, Eleanor has a higher standardized score, we can conclude that Eleanor did better!

Radio (Two Column)

Which of these two scatterplots have a higher correlation?

  1. A
  2. B

Both have the same correlation.

Checkbox

Linda is 31 years old, single, outspoken, and very bright. She majored in philosophy. As a student, she was deeply concerned with issues of discrimination and social justice, and also participated in anti-nuclear demonstrations.

Which is more probable?

  1. Linda is a bank teller.
  2. Linda is a bank teller and is active in the feminist movement.

Think about the probabilities of each event, and that of both of them together.

If you chose (2), stop back and think. Suppose we denote the event of Linda being a teller by A and the event she is active in the feminist movement by B, then probabilities in question can be written as.

  • P(A)
  • \(P(A \cap B)\)

This is called the conjugacy fallacy that occurs when it is assumed that specific conditions are more probable than a single general one.

Multi Text

The length of human pregnancies from conception to birth varies according to a distribution that is approximately Normal with mean 266 days and standard deviation 16 days.

  1. What percent of pregnancies last fewer than 240 days?
  2. What percent of pregnancies last between 240 and 270 days?
  3. How long do the longest 25% pregnancies last?
  1. 5.2081279
  2. 54.6625046
  3. 276.791836

This is a hint

Submit and Compare

What is the sample space for this experiment?

Submit and Compare Clear

Submit and Compare (2 Column)

The solid curve represents the distribution of heights of all males in the US. The dotted curve represents the distribution of heights reported by males on OkCupid, an online dating website.

What is happening here?

Submit and Compare Clear

Interactivity

Interactive Console

HTML widgets

HTML widget library

HTML widgets are interactive graphics made for the web. These are the main libraries available:

leaflet

dygraphs

dygraphs (cont)

dygraphs (cont)

dygraphs (cont)

metricsgraphics

metricsgraphics (cont)

metricsgraphics (cont)

metricsgraphics (cont)

metricsgraphics (cont)

metricsgraphics (cont)

networkD3

networkD3 (cont)

DT

threejs

threejs (cont)

DiagrammeR

DiagrammeR (cont)