class: center, middle, inverse, title-slide # Presentation Ninja ## ⚔
with xaringan and xaringanthemer ### Yihui Xie ### 2020-04-04 --- class: center, middle # xaringan ### /ʃæ.'riŋ.ɡæn/ --- class: inverse, center, middle # Get Started --- class: header_background # Hello World Install the **xaringan** package from [Github](https://github.com/yihui/xaringan): ```r devtools::install_github("yihui/xaringan") ``` -- .bg-light-blue[You are recommended] to use the [RStudio IDE](https://www.rstudio.com/products/rstudio/), but you do not have to. - Create a .blue[new R Markdown document] from the menu `File -> New File -> R Markdown -> From Template -> Ninja Presentation`;<sup>1</sup> -- - Click the `Knit` button to compile it; -- - or use the [RStudio Addin](https://rstudio.github.io/rstudioaddins/)<sup>2</sup> "Infinite Moon Reader" to live preview the slides (every time you update and save the Rmd document, the slides will be automatically reloaded in RStudio Viewer. .footnote[ [1] 中文用户请看[这份教程](http://slides.yihui.name/xaringan/zh-CN.html) [2] See [#2](https://github.com/yihui/xaringan/issues/2) if you do not see the template or addin in RStudio. ] --- # A Quote > There one was a man from Nantucket. Whose heart was stuck in a bucket. --- ```r library(ggplot2) ggplot(iris) + aes(Petal.Length, Petal.Width) + geom_point() + theme_xaringan() ``` <!-- --> --- background-image: url(https://github.com/yihui/xaringan/releases/download/v0.0.2/karl-moustache.jpg) background-position: 50% 50% class: center, bottom, inverse # You only live once! --- # Hello Ninja As a presentation ninja, you certainly should not be satisfied by the "Hello World" example. You need to understand more about two things: 1. The [remark.js](https://remarkjs.com) library; 1. The **xaringan** package; Basically **xaringan** injected the chakra of R Markdown (minus Pandoc) into **remark.js**. The slides are rendered by remark.js in the web browser, and the Markdown source needed by remark.js is generated from R Markdown (**knitr**). --- # remark.js You can see an introduction of remark.js from [its homepage](https://remarkjs.com). You should read the [remark.js Wiki](https://github.com/gnab/remark/wiki) at least once to know how to - create a new slide (Markdown syntax<sup>*</sup> and slide properties); - format a slide (e.g. text alignment); - configure the slideshow; - and use the presentation (keyboard shortcuts). It is important to be familiar with remark.js before you can understand the options in **xaringan**. .footnote[[*] It is different with Pandoc's Markdown! It is limited but should be enough for presentation purposes. Come on... You do not need a slide for the Table of Contents! Well, the Markdown support in remark.js [may be improved](https://github.com/gnab/remark/issues/142) in the future.] --- background-image: url(https://github.com/yihui/xaringan/releases/download/v0.0.2/karl-moustache.jpg) background-size: cover class: center, bottom, inverse # I was so happy to have discovered remark.js! --- class: inverse, middle, center # Using xaringan --- # xaringan Provides an R Markdown output format `xaringan::moon_reader` as a wrapper for remark.js, and you can use it in the YAML metadata, e.g. ```yaml --- title: "A Cool Presentation" output: xaringan::moon_reader yolo: true nature: autoplay: 30000 --- ``` See the help page `?xaringan::moon_reader` for all possible options that you can use. --- # remark.js vs xaringan Some differences between using remark.js (left) and using **xaringan** (right): .pull-left[ 1. Start with a boilerplate HTML file; 1. Plain Markdown; 1. Write JavaScript to autoplay slides; 1. Manually configure MathJax; 1. Highlight code with `*`; 1. Edit Markdown source and refresh browser to see updated slides; ] .pull-right[ 1. Start with an R Markdown document; 1. R Markdown (can embed R/other code chunks); 1. Provide an option `autoplay`; 1. MathJax just works;<sup>*</sup> 1. Highlight code with `{{}}`; 1. The RStudio addin "Infinite Moon Reader" automatically refreshes slides on changes; ] .footnote[[*] Not really. See next page.]