This is an R Markdown document created with examples of how to work with slidify. Based on Coursera’s Data Products course.
You need to install it and load it
library(devtools)
install_github('slidify', 'ramnathv')
install_github('slidifyLibraries', 'ramnathv')
Set the working directory to where you want to create your Slidify project
setwd("./projects/")
Create your project and give your project a name (My project is named “example_project”)
library(slidify)
author("example_project")
Then, automatically:
index.Rmd R Markdown file will open up in RStudio.The content of the slides should be included in the index.RMD file, which looks like this:
index.Rmd is the R Markdown document which you will use to compose the conent of your presentation.index.Rmd file is a bit of YAML code which will starts with a header 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}
---
You can fill in your title, subtitle, author name and job, save index.RMD and type
slidify('index.Rmd')
That creates an index.html file which is composed of slides! You could also use the knitr html on Rstudio. ```
Let’s look once again at the (so-called YAML, which stands for yet another markup language) that the index.Rmd file beings with (now I filled it a bit):
---
title : My title
subtitle : My subtitle
author : Obviously me
job : Doing stuff
framework : io2012 # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js # {highlight.js, prettify, highlight}
hitheme : tomorrow #
widgets : [mathjax, quiz, bootstrap, interactive] # {mathjax, quiz, bootstrap}
mode : selfcontained # {standalone, draft}
knit : slidify::knit2slides
ext_widgets: {rCharts: [libraries/nvd3]}
---
The framework accounts for the formatting. As you see, there are several options besides io2012. Highlighter accounts for some of the effects. Widgets allow you do include stuff (mathjax allows you to include Latex code, which you can put it in between 2 dollar signs or 2 pairs of dollar signs; quiz allows you do do quizes as we will see). The mode should be chosen taking into account whether or not you will have internet access when you want to display the slides. The rcharts “ext_widget” allows including rcharts. This is what the first page of the slidified document will look like:
If you type
--- &radio
## Question 1
What is 1 + 1?
*** .hint This is a hint
*** .explanation This is an explanation
you get an interactive question:
If you type:
require(rCharts)
haireye = as.data.frame(HairEyeColor)
n1 <- nPlot(Freq ~ Hair, group = 'Eye', type = 'multiBarChart',
data = subset(haireye, Sex == 'Male')
)
n1$print('chart1')
with option echo = F, results = ‘asis’ you will embed the following rChart on the slides:
user with your username and repo with the name of your new repository (both arguments are strings).publish_github(user, repo)