background-color: #006DAE class: middle center hide-slide-number <div class="shade_black" style="width:60%;right:0;bottom:0;padding:10px;border: dashed 4px white;margin: auto;"> <i class="fas fa-exclamation-circle"></i> These slides are viewed best by Chrome and occasionally need to be refreshed if elements did not load properly. See <a href=/>here for PDF <i class="fas fa-file-pdf"></i></a>. </div> <br> .white[Press the **right arrow** to progress to the next slide!] --- background-image: url(images/bg1.jpg) background-size: cover class: hide-slide-number title-slide count: false <div style="position: absolute; left: 30%; top: 15%; width:50%"> <h1 class="monash-blue">Beyond Beamer</h1> <h2 style="font-weight:900!important;">Modern and Dynamic Presentations with<br> R Markdown</h2> </div> .bottom_abs.width100.shade_black[ <img src="images/monash-logo.png" style="float:right;" height = "120px"/> **Emi Tanaka** Department of Econometrics and Business Statistics
<i class="fas fa-envelope faa-float animated "></i>
emi.tanaka@monash.edu
<i class="fab fa-twitter faa-float animated "></i>
@statsgen 30th Jun 2020 @ SSA NSW/Canberra x R-Ladies Sydney/Canberra | via Zoom ] <img src="images/host-logo.png" style="position:absolute;top:45%;left:57%;" height = "190px"/> --- layout: true .footer[ <a href="https://twitter.com/statsgen"><i class="fab fa-twitter"></i>@statsgen</a> <i class="fas fa-link"></i> <a href="http://emitanaka.org/slides/rladiesSSA2020/#1">emitanaka.org/slides/rladiesSSA2020/</a> ] --- background-image: url("images/bg2.jpg") background-size: cover name: download # Link to all the materials * This slide is made using R markdown via the `xaringan` R-package 📦 * You can find [all material here <i class="fab fa-github"></i> ](https://github.com/emitanaka/rladiesSSA2020) or [download as zip here <i class="fa fa-download"></i> ](https://github.com/emitanaka/rladiesSSA2020/zipball/master/) <iframe frameborder=0 src="index.html#2" style="position:absolute;top:28.5%;left:27.46%;width:533.33px;height:300px;"></iframe> --- class: monash-bg-blue center middle white
<i class="fas fa-exclamation-triangle fa-3x faa-flash animated faa-slow "></i>
<br> This talk is NOT about: -- <br> <i class='fa fa-times'></i> how to present well or communicate -- <br> <i class='fa fa-times'></i> how to design your slides --- class: monash-bg-blue center middle white <span style="font-size:3em">🎯</span> <br> <i class='fas fa-check'></i> Learn about Beamer <i class="fas fa-handshake"></i> R Markdown -- <br> <i class='fas fa-check'></i> Why care about R Markdown? -- <br> <i class='fas fa-check'></i> Get started with `xaringan` = R Markdown <i class="fas fa-handshake"></i> `remark.js` <i class="fas fa-user-plus"></i> HTML/CSS/JS -- <br> <i class='fas fa-check'></i> Why HTML slides? -- <br> <i class="fas fa-question-circle"></i> Questions? Do ask away! <span style="font-size:3em">👩🏻💻</span> --- background-image: url("images/bg3.jpg") background-size: cover <div class="cursive-font" style="font-size:34pt!important;position:absolute;top:50%;left:30%;transform:rotate(6deg);width:500px;"> For the beamer users who are yet to use <br>R Markdown </div> --- # Beamer LaTeX document class .grid[ .item[ `example-beamer-clean.tex` .scroll-fit50[ ````{=latex} \documentclass[10pt,aspectratio=169]{beamer} \usepackage{amssymb,amsmath} \usepackage{lmodern} \usepackage{hyperref, url} \usetheme{Copenhagen} \usecolortheme{dolphin} \usefonttheme{structurebold} \title{This is a Beamer presentation made using \LaTeX} \subtitle{} \author{Emi Tanaka} \date{30th June 2020} \institute{Monash University} \begin{document} \frame{\titlepage} \begin{frame} \tableofcontents[hideallsubsections] \end{frame} \section{Basics} \begin{frame}{Setting up the YAML} \begin{block}{R Markdown YAML} \texttt{output:\ beamer\_presentation} \end{block} Also check out the \href{https://github.com/eddelbuettel/binb}{\texttt{binb} R-package}. \end{frame} \section{Clean syntax} \begin{frame}{Example: Writing mathematics is as usual} Consider a general linear mixed models: $\boldsymbol{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{Z}\boldsymbol{u} + \boldsymbol{e}$ where \begin{itemize} \item $\boldsymbol{y}$ is a $n\times 1$ vector of observations, \item $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, \item $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and \item $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{itemize} \end{frame} \begin{frame}[fragile]{Simplified content writing: itemized list} \begin{columns}[T] \begin{column}{0.48\textwidth} \begin{block}{Plain \LaTeX} \small \begin{verbatim} \begin{itemize} \item $\boldsymbol{y}$ is a $n\times 1$ vector of observations, \item $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$$, \item $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and \item $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{itemize} \end{verbatim} \end{block} \end{column} \begin{column}{0.48\textwidth} \begin{block}{Markdown syntax} \small \vspace{0.5cm} \begin{verbatim} * $\boldsymbol{y}$ is a $n\times 1$ vector of observations, * $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, * $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and * $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{verbatim} \end{block} \end{column} \end{columns} \end{frame} \begin{frame}[fragile]{Make new frame} \begin{columns}[T] \begin{column}{0.48\textwidth} Instead of \begin{block}{\LaTeX} \begin{verbatim} \begin{frame}{Title} Content \ end{frame} \end{verbatim} \end{block} do \begin{block}{markdown} \begin{verbatim} ## Title Content \end{verbatim} \end{block} \end{column} \begin{column}{0.48\textwidth} In the \textbf{R Markdown YAML} set: \begin{verbatim} output: beamer_presentation: slide_level: 2 \end{verbatim} \begin{itemize} \item then a heading at slide level starts a new frame; or \item a horizontal line, like \texttt{-\/-\/-}, starts a new frame. \end{itemize} \end{column} \end{columns} \end{frame} \begin{frame}[fragile]{Multi-column output} Stick with \LaTeX or Pandoc syntax (both will work) \begin{columns}[T] \begin{column}{0.48\textwidth} \begin{block}{Plain \LaTeX} \begin{verbatim} \begin{columns} \begin{column}{0.5\textwidth} Column 1 content \end{column} \begin{column}{0.5\textwidth} Column 2 content \end{column} \end{columns} \end{verbatim} \end{block} \end{column} \begin{column}{0.48\textwidth} \begin{block}{Pandoc syntax} \begin{verbatim} :::: columns ::: column Column 1 content ::: ::: column Column 2 content ::: :::: \end{verbatim} \end{block} \end{column} \end{columns} \end{frame} \section{Appearance} \begin{frame}[fragile]{Pandoc options} \begin{itemize} \item See \href{https://pandoc.org/MANUAL.html\#variables-for-beamer-slides}{Pandoc manual} for all the variables available to modify in the YAML. \begin{itemize} \item E.g. \texttt{aspectratio:\ 43} for 4:3 ratio. \end{itemize} \item See also \href{https://pandoc.org/MANUAL.html\#producing-slide-shows-with-pandoc}{Producing slide shows with pandoc} \begin{itemize} \item E.g. Speaker notes \end{itemize} \end{itemize} \end{frame} \begin{frame}[fragile,shrink]{Beamer frame atributes} \begin{verbatim} ## Beamer frame atributes {.shrink} \end{verbatim} \begin{itemize} \item The frame attributes in Section 8.1 of the \href{http://mirror.aarnet.edu.au/pub/CTAN/macros/latex/contrib/beamer/doc/beameruserguide.pdf}{Beamer User's Guide} can be used if inserted after header level as \texttt{\{.attribute\}} where \texttt{attribute} replaced with \begin{itemize} \item \texttt{allowdisplaybreaks} \item \texttt{allowframebreaks} \item \texttt{b} \item \texttt{c} \item \texttt{t} \item \texttt{environment} \item \texttt{label} \item \texttt{plain} \item \texttt{shrink} \item \texttt{standout} \item \texttt{noframenumbering} \end{itemize} \end{itemize} \end{frame} \section{Animation} \begin{frame}[fragile]{Animation} \begin{itemize}[<+->] \item First step \item Second step \item Third step \end{itemize} \pause You can also include pauses with \texttt{.\ .\ .} \end{frame} \end{document} ```` ]] .item[ `example-beamer-clean.pdf` <br> <div class="w3-display-container"> <center> <img class='mySlides1' src='images/example-beamer-clean_1.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_2.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_3.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_4.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_5.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_6.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_7.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_8.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_9.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_10.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_11.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_12.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_13.png' width='98%'> <img class='mySlides1' src='images/example-beamer-clean_14.png' width='98%'> <button class="w3-button w3-black w3-display-left" onclick="plusDivs(-1, 0)">❮</button> <button class="w3-button w3-black w3-display-right" onclick="plusDivs(1, 0)">❯</button> </center> </div> ] ] --- # Clean syntax with Markdown .grid[ .item[ `example-beamer-clean.tex` .scroll-fit50[ ````latex \documentclass[10pt,aspectratio=169]{beamer} \usepackage{amssymb,amsmath} \usepackage{lmodern} \usepackage{hyperref, url} \usetheme{Copenhagen} \usecolortheme{dolphin} \usefonttheme{structurebold} \title{This is a Beamer presentation made using \LaTeX} \subtitle{} \author{Emi Tanaka} \date{30th June 2020} \institute{Monash University} \begin{document} \frame{\titlepage} \begin{frame} \tableofcontents[hideallsubsections] \end{frame} \section{Basics} \begin{frame}{Setting up the YAML} \begin{block}{R Markdown YAML} \texttt{output:\ beamer\_presentation} \end{block} Also check out the \href{https://github.com/eddelbuettel/binb}{\texttt{binb} R-package}. \end{frame} \section{Clean syntax} \begin{frame}{Example: Writing mathematics is as usual} Consider a general linear mixed models: $\boldsymbol{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{Z}\boldsymbol{u} + \boldsymbol{e}$ where \begin{itemize} \item $\boldsymbol{y}$ is a $n\times 1$ vector of observations, \item $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, \item $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and \item $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{itemize} \end{frame} \begin{frame}[fragile]{Simplified content writing: itemized list} \begin{columns}[T] \begin{column}{0.48\textwidth} \begin{block}{Plain \LaTeX} \small \begin{verbatim} \begin{itemize} \item $\boldsymbol{y}$ is a $n\times 1$ vector of observations, \item $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$$, \item $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and \item $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{itemize} \end{verbatim} \end{block} \end{column} \begin{column}{0.48\textwidth} \begin{block}{Markdown syntax} \small \vspace{0.5cm} \begin{verbatim} * $\boldsymbol{y}$ is a $n\times 1$ vector of observations, * $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, * $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and * $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{verbatim} \end{block} \end{column} \end{columns} \end{frame} \begin{frame}[fragile]{Make new frame} \begin{columns}[T] \begin{column}{0.48\textwidth} Instead of \begin{block}{\LaTeX} \begin{verbatim} \begin{frame}{Title} Content \ end{frame} \end{verbatim} \end{block} do \begin{block}{markdown} \begin{verbatim} ## Title Content \end{verbatim} \end{block} \end{column} \begin{column}{0.48\textwidth} In the \textbf{R Markdown YAML} set: \begin{verbatim} output: beamer_presentation: slide_level: 2 \end{verbatim} \begin{itemize} \item then a heading at slide level starts a new frame; or \item a horizontal line, like \texttt{-\/-\/-}, starts a new frame. \end{itemize} \end{column} \end{columns} \end{frame} \begin{frame}[fragile]{Multi-column output} Stick with \LaTeX or Pandoc syntax (both will work) \begin{columns}[T] \begin{column}{0.48\textwidth} \begin{block}{Plain \LaTeX} \begin{verbatim} \begin{columns} \begin{column}{0.5\textwidth} Column 1 content \end{column} \begin{column}{0.5\textwidth} Column 2 content \end{column} \end{columns} \end{verbatim} \end{block} \end{column} \begin{column}{0.48\textwidth} \begin{block}{Pandoc syntax} \begin{verbatim} :::: columns ::: column Column 1 content ::: ::: column Column 2 content ::: :::: \end{verbatim} \end{block} \end{column} \end{columns} \end{frame} \section{Appearance} \begin{frame}[fragile]{Pandoc options} \begin{itemize} \item See \href{https://pandoc.org/MANUAL.html\#variables-for-beamer-slides}{Pandoc manual} for all the variables available to modify in the YAML. \begin{itemize} \item E.g. \texttt{aspectratio:\ 43} for 4:3 ratio. \end{itemize} \item See also \href{https://pandoc.org/MANUAL.html\#producing-slide-shows-with-pandoc}{Producing slide shows with pandoc} \begin{itemize} \item E.g. Speaker notes \end{itemize} \end{itemize} \end{frame} \begin{frame}[fragile,shrink]{Beamer frame atributes} \begin{verbatim} ## Beamer frame atributes {.shrink} \end{verbatim} \begin{itemize} \item The frame attributes in Section 8.1 of the \href{http://mirror.aarnet.edu.au/pub/CTAN/macros/latex/contrib/beamer/doc/beameruserguide.pdf}{Beamer User's Guide} can be used if inserted after header level as \texttt{\{.attribute\}} where \texttt{attribute} replaced with \begin{itemize} \item \texttt{allowdisplaybreaks} \item \texttt{allowframebreaks} \item \texttt{b} \item \texttt{c} \item \texttt{t} \item \texttt{environment} \item \texttt{label} \item \texttt{plain} \item \texttt{shrink} \item \texttt{standout} \item \texttt{noframenumbering} \end{itemize} \end{itemize} \end{frame} \section{Animation} \begin{frame}[fragile]{Animation} \begin{itemize}[<+->] \item First step \item Second step \item Third step \end{itemize} \pause You can also include pauses with \texttt{.\ .\ .} \end{frame} \end{document} ```` ] ] .item[ `example-beamer.Rmd` .scroll-fit50[ ````yaml --- title: This is a Beamer presentation made using R Markdown subtitle: "`rmarkdown::beamer_presentation`" author: Emi Tanaka institute: Monash University date: "30th June 2020" fontsize: 10pt mathspec: true # for metropolis theme aspectratio: 169 # 16:9 #classoption: handout output: beamer_presentation: theme: "Copenhagen" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_theme.html #theme: "metropolis" # special colortheme: "dolphin" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_color.html fonttheme: "structurebold" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_font.html latex_engine: xelatex # for metropolis theme toc: true slide_level: 2 keep_tex: true #includes: # in_header: preamble.tex header-includes: - \usepackage{fancyvrb} --- ```` ````markdown # Basics ## Setting up the YAML ::: block ### R Markdown YAML `output: beamer_presentation` ::: Also check out the [`binb` R-package](https://github.com/eddelbuettel/binb). # Clean syntax ## Example: Writing mathematics is as usual Consider a general linear mixed models: $$\boldsymbol{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{Z}\boldsymbol{u} + \boldsymbol{e}$$ where * $\boldsymbol{y}$ is a $n\times 1$ vector of observations, * $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, * $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and * $\boldsymbol{e}$ is a $n\times 1$ vector of random error. ## Simplified content writing: itemized list :::::: columns ::: column ### Plain \LaTeX \small ``` \begin{itemize} \item $\boldsymbol{y}$ is a $n\times 1$ vector of observations, \item $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$$, \item $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and \item $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{itemize} ``` ::: ::: column ### Markdown syntax \small \vspace{0.5cm} ``` * $\boldsymbol{y}$ is a $n\times 1$ vector of observations, * $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, * $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and * $\boldsymbol{e}$ is a $n\times 1$ vector of random error. ``` ::: :::::: ## Make new frame {.fragile} ::: columns ::: column Instead of ::: block ### \LaTeX ``` \begin{frame}{Title} Content \ end{frame} ``` ::: do ### markdown ``` ## Title Content ``` ::: ::: column In the **R Markdown YAML** set: ``` output: beamer_presentation: slide_level: 2 ``` * then a heading at slide level starts a new frame; or * a horizontal line, like `---`, starts a new frame. ::: ::: ## Multi-column output Stick with \LaTeX or Pandoc syntax (both will work) :::: columns ::: column ### Plain \LaTeX ``` \begin{columns} \begin{column}{0.5\textwidth} Column 1 content \end{column} \begin{column}{0.5\textwidth} Column 2 content \end{column} \end{columns} ``` ::: ::: column ### Pandoc syntax ``` :::: columns ::: column Column 1 content ::: ::: column Column 2 content ::: :::: ``` ::: :::: # Appearance ## Pandoc options * See [Pandoc manual](https://pandoc.org/MANUAL.html#variables-for-beamer-slides) for all the variables available to modify in the YAML. * E.g. `aspectratio: 43` for 4:3 ratio. * See also [Producing slide shows with pandoc](https://pandoc.org/MANUAL.html#producing-slide-shows-with-pandoc) * E.g. Speaker notes ## Beamer frame atributes {.shrink} ``` ## Beamer frame atributes {.shrink} ``` * The frame attributes in Section 8.1 of the [Beamer User's Guide](http://mirror.aarnet.edu.au/pub/CTAN/macros/latex/contrib/beamer/doc/beameruserguide.pdf) can be used if inserted after header level as `{.attribute}` where `attribute` replaced with * `allowdisplaybreaks` * `allowframebreaks` * `b` * `c` * `t` * `environment` * `label` * `plain` * `shrink` * `standout` * `noframenumbering` # Animation ::: incremental * First step * Second step * Third step ::: . . . You can also include pauses with `. . . ` ```{r export, include = FALSE} library(pdftools) pdf_convert("example-beamer.pdf", format = "png", dpi = 200) fns <- list.files(pattern = "example-beamer_") purrr::walk(fns, ~{ file.copy(.x, paste0("images/", .x), overwrite = TRUE) file.remove(.x) }) ``` ```` ] ] ] --- # Beamer LaTeX with R Markdown .grid[ .item[ `example-beamer`.monash-blue[`.Rmd`] .scroll-fit50[ ````yaml --- title: This is a Beamer presentation made using R Markdown subtitle: "`rmarkdown::beamer_presentation`" author: Emi Tanaka institute: Monash University date: "30th June 2020" fontsize: 10pt mathspec: true # for metropolis theme aspectratio: 169 # 16:9 #classoption: handout output: beamer_presentation: theme: "Copenhagen" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_theme.html #theme: "metropolis" # special colortheme: "dolphin" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_color.html fonttheme: "structurebold" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_font.html latex_engine: xelatex # for metropolis theme toc: true slide_level: 2 keep_tex: true #includes: # in_header: preamble.tex header-includes: - \usepackage{fancyvrb} --- ```` ````markdown # Basics ## Setting up the YAML ::: block ### R Markdown YAML `output: beamer_presentation` ::: Also check out the [`binb` R-package](https://github.com/eddelbuettel/binb). # Clean syntax ## Example: Writing mathematics is as usual Consider a general linear mixed models: $$\boldsymbol{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{Z}\boldsymbol{u} + \boldsymbol{e}$$ where * $\boldsymbol{y}$ is a $n\times 1$ vector of observations, * $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, * $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and * $\boldsymbol{e}$ is a $n\times 1$ vector of random error. ## Simplified content writing: itemized list :::::: columns ::: column ### Plain \LaTeX \small ``` \begin{itemize} \item $\boldsymbol{y}$ is a $n\times 1$ vector of observations, \item $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$$, \item $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and \item $\boldsymbol{e}$ is a $n\times 1$ vector of random error. \end{itemize} ``` ::: ::: column ### Markdown syntax \small \vspace{0.5cm} ``` * $\boldsymbol{y}$ is a $n\times 1$ vector of observations, * $\mathbf{X}$ is a $n\times p$ design matrix for fixed effects $\boldsymbol{\beta}$, * $\mathbf{Z}$ is a $n\times q$ design matrix for fixed effects $\boldsymbol{u}$, and * $\boldsymbol{e}$ is a $n\times 1$ vector of random error. ``` ::: :::::: ## Make new frame {.fragile} ::: columns ::: column Instead of ::: block ### \LaTeX ``` \begin{frame}{Title} Content \ end{frame} ``` ::: do ### markdown ``` ## Title Content ``` ::: ::: column In the **R Markdown YAML** set: ``` output: beamer_presentation: slide_level: 2 ``` * then a heading at slide level starts a new frame; or * a horizontal line, like `---`, starts a new frame. ::: ::: ## Multi-column output Stick with \LaTeX or Pandoc syntax (both will work) :::: columns ::: column ### Plain \LaTeX ``` \begin{columns} \begin{column}{0.5\textwidth} Column 1 content \end{column} \begin{column}{0.5\textwidth} Column 2 content \end{column} \end{columns} ``` ::: ::: column ### Pandoc syntax ``` :::: columns ::: column Column 1 content ::: ::: column Column 2 content ::: :::: ``` ::: :::: # Appearance ## Pandoc options * See [Pandoc manual](https://pandoc.org/MANUAL.html#variables-for-beamer-slides) for all the variables available to modify in the YAML. * E.g. `aspectratio: 43` for 4:3 ratio. * See also [Producing slide shows with pandoc](https://pandoc.org/MANUAL.html#producing-slide-shows-with-pandoc) * E.g. Speaker notes ## Beamer frame atributes {.shrink} ``` ## Beamer frame atributes {.shrink} ``` * The frame attributes in Section 8.1 of the [Beamer User's Guide](http://mirror.aarnet.edu.au/pub/CTAN/macros/latex/contrib/beamer/doc/beameruserguide.pdf) can be used if inserted after header level as `{.attribute}` where `attribute` replaced with * `allowdisplaybreaks` * `allowframebreaks` * `b` * `c` * `t` * `environment` * `label` * `plain` * `shrink` * `standout` * `noframenumbering` # Animation ::: incremental * First step * Second step * Third step ::: . . . You can also include pauses with `. . . ` ```{r export, include = FALSE} library(pdftools) pdf_convert("example-beamer.pdf", format = "png", dpi = 200) fns <- list.files(pattern = "example-beamer_") purrr::walk(fns, ~{ file.copy(.x, paste0("images/", .x), overwrite = TRUE) file.remove(.x) }) ``` ```` ]] .item[ `example-beamer.pdf` <br> <div class="w3-display-container"> <center> <img class='mySlides2' src='images/example-beamer_1.png' width='98%'> <img class='mySlides2' src='images/example-beamer_2.png' width='98%'> <img class='mySlides2' src='images/example-beamer_3.png' width='98%'> <img class='mySlides2' src='images/example-beamer_4.png' width='98%'> <img class='mySlides2' src='images/example-beamer_5.png' width='98%'> <img class='mySlides2' src='images/example-beamer_6.png' width='98%'> <img class='mySlides2' src='images/example-beamer_7.png' width='98%'> <img class='mySlides2' src='images/example-beamer_8.png' width='98%'> <img class='mySlides2' src='images/example-beamer_9.png' width='98%'> <img class='mySlides2' src='images/example-beamer_10.png' width='98%'> <img class='mySlides2' src='images/example-beamer_11.png' width='98%'> <img class='mySlides2' src='images/example-beamer_12.png' width='98%'> <img class='mySlides2' src='images/example-beamer_13.png' width='98%'> <img class='mySlides2' src='images/example-beamer_14.png' width='98%'> <img class='mySlides2' src='images/example-beamer_15.png' width='98%'> <img class='mySlides2' src='images/example-beamer_16.png' width='98%'> <img class='mySlides2' src='images/example-beamer_17.png' width='98%'> <img class='mySlides2' src='images/example-beamer_18.png' width='98%'> <img class='mySlides2' src='images/example-beamer_19.png' width='98%'> <img class='mySlides2' src='images/example-beamer_files' width='98%'> <button class="w3-button w3-black w3-display-left" onclick="plusDivs(-1, 1)">❮</button> <button class="w3-button w3-black w3-display-right" onclick="plusDivs(1, 1)">❯</button> </center> </div> ] ] --- # Why care about R Markdown? .info-box.margin50[ <i class='fas fa-check'></i> Clean syntax for writing content <i class='fas fa-check'></i> Integrates code and output easily: * great for tutorials, workshops, lectures to demonstrate how to use code * great for presenting analytical results <i class='fas fa-check'></i> Some code syntax highlighting code done for you <br> .grid[ .item.font_smaller[ *Verbatim code* ```text mtcars %>% mutate(new = 30, string = "hello") ``` ] .item.font_smaller[ *Syntax highlighting* ```r mtcars %>% mutate(new = 30, string = "hello") ``` (achieved commonly using `listings` package in LaTeX) ] ] ] --- # R Markdown <i class="fas fa-handshake"></i> Beamer .grid[ .item[ `example-beamer2.Rmd` .scroll-fit50[ ````yaml --- title: The Power of R Markdown subtitle: "`rmarkdown::beamer_presentation`" author: Emi Tanaka institute: Monash University date: "30th June 2020" fontsize: 10pt mathspec: true # for metropolis theme aspectratio: 169 # 16:9 #classoption: handout output: beamer_presentation: theme: "Madrid" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_theme.html #theme: "metropolis" # special colortheme: "whale" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_color.html fonttheme: "professionalfonts" # https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_font.html latex_engine: xelatex # for metropolis theme toc: false slide_level: 2 keep_tex: true #includes: # in_header: preamble.tex header-includes: - \usepackage{fancyvrb} - \usepackage{graphicx} --- ```` ````markdown # Power of R Markdown ## Example: my fancy graph Behold! My plot that shows the linear trend! ```{r myplot, echo = FALSE, message = FALSE, fig.align = "center", fig.height = 2, fig.width = 4} library(tidyverse) ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point() + theme_bw(base_size = 18) ``` ## Example: code and output demonstration This is how you use `tidyverse` to fit simple linear models to each level in `cyl` . ```{r pkgshow, message = FALSE} library(tidyverse) mtcars %>% split(.$cyl) %>% map_dfr(~{ fit <- lm(mpg ~ disp, data = .) slope_ests <- coef(fit) c(cyl = .$cyl[1], n = nrow(.), slope_ests) }) ``` ## R Markdown Motivation: More robust to modifications ```{r, echo = FALSE, out.width = "100%"} knitr::include_graphics("images/rmd-motivation.png") ``` ```{r export, include = FALSE} library(pdftools) pdf_convert("example-beamer2.pdf", format = "png", dpi = 200) fns <- list.files(pattern = "example-beamer2_") purrr::walk(fns, ~{ file.copy(.x, paste0("images/", .x), overwrite = TRUE) file.remove(.x) }) ``` ```` ]] .item[ `example-beamer2.pdf` <br> <div class="w3-display-container"> <center> <img class='mySlides3' src='images/example-beamer2_1.png' width='98%'> <img class='mySlides3' src='images/example-beamer2_2.png' width='98%'> <img class='mySlides3' src='images/example-beamer2_3.png' width='98%'> <img class='mySlides3' src='images/example-beamer2_4.png' width='98%'> <img class='mySlides3' src='images/example-beamer2_5.png' width='98%'> <button class="w3-button w3-black w3-display-left" onclick="plusDivs(-1, 2)">❮</button> <button class="w3-button w3-black w3-display-right" onclick="plusDivs(1, 2)">❯</button> </center> </div> ] ] --- background-image: url("images/bg4.jpg") background-size: 120% <div class="cursive-font" style="font-size:30pt!important;position:absolute;top:60%;left:40%;transform:rotate(20deg);width:30%;"> For those that want to learn about `xaringan` </div> --- background-image: url("images/bg5.jpg") background-size: 100% # Getting started with `xaringan` <iframe frameborder=0 src="https://slides.yihui.org/xaringan/#1" style="position:absolute;top:24.55%;left:27.46%;width:533.33px;height:390px;"></iframe> --- background-image: url("images/bg5.jpg") background-size: 100% # Check out Earo Wang's talk at R-Ladies Auckland Slide + Code [here](https://earo.me/talk/rladiesakl20/). <iframe frameborder=0 src="https://slides.earo.me/rladiesakl20/#1" style="position:absolute;top:24.55%;left:27.46%;width:533.33px;height:390px;"></iframe> --- background-image: url("images/bg5.jpg") background-size: 100% # Also Alison Hill's slides! <iframe frameborder=0 src="https://arm.rbind.io/slides/xaringan.html#1" style="position:absolute;top:24.55%;left:27.46%;width:533.33px;height:390px;"></iframe> --- # <i class="fas fa-user-ninja"></i> Getting started with `xaringan` slides ```r install.packages("xaringan") ``` `RStudio > File > New File > R Markdown > From Template > Ninja Presentation` <br> * You do have to know HTML/CSS * JS helps as well -- * But if you don't know then ```r install.packages("xaringanthemer") ``` `RStudio > File > New File > R Markdown > From Template > Ninja Themed Presentation` --- class: font_smaller # <i class="fab fa-html5"></i> Why HTML slides?
Interactivity!
Animate!
```r DT::datatable(mtcars) ```
--- class: font_small # <i class="fas fa-mouse-pointer"></i> Interactive plots into html slides .grid[.item[ ```r library(plotly) # for interactive plots g <- ggplot(mtcars) + aes(mpg, disp, color = factor(cyl)) + geom_point() + theme_bw(base_size = 20) p <- ggplotly(g) htmltools::save_html(p, file = "example-plotly.html") ``` Doable, but slightly fiddly to embed in slides ([see Di Cook's blog](http://dicook.org/2018/08/29/getting-past-the-little-hiccups-to-getting-plotly-animations-into-slides/)). ``` <iframe src="example-plotly.html" width="550" height="500"></iframe> ``` ] .item[ <iframe src="example-plotly.html" width="550" height="500"></iframe> ] ] --- # <i class="fas fa-chalkboard-teacher"></i> Side-by-side code and output demo * See also [`flipbooks` talk by Gina Reynolds](https://rstudio.com/resources/rstudioconf-2020/flipbooks-evangeline-reynolds/) and her [`flipbookr`](https://github.com/EvaMaeRey/flipbookr) R-package. * This uses the code from [here by me](https://gist.github.com/emitanaka/99c5673ddc8f9103dd3c8fec05ab15ea) and shortened [here by Garrick](https://gist.github.com/gadenbuie/634060984f0007bf390a931dd3b31bab). .grid[ .item[ .scroll-fit50[ ````yaml --- title: "ggplot tutorial" subtitle: "with kunoichi + ninjutsu theme" author: "<br><br> Emi Tanaka" date: "<br>2018/09/16" output: xaringan::moon_reader: lib_dir: libs2 css: ["kunoichi", "ninjutsu"] nature: ratio: "16:9" highlightLines: true --- ```` ````markdown ```{r setup, include=FALSE} knitr::opts_chunk$set(echo=TRUE) knitr::opts_chunk$set(fig.height=6, out.width="100%") library(ggplot2) # reveal lines up to `upto` and highlight lines `highlight` reveal <- function(name, upto, highlight = upto) { content <- knitr:::knit_code$get(name) content[upto] <- gsub("+", "", content[upto], fixed=T) content[highlight] <- paste(content[highlight], "#<<") content[1:upto] } partial_knit_chunks <- function(chunk_name) { # Create slide for lines 1:N for each line N in the given chunk idx_lines <- seq_along(knitr:::knit_code$get(chunk_name)) partial_knit_steps <- glue::glue( "class: split-40", "count: false", "", ".column[.content[", "```{r plot{{idx_lines}}, eval=FALSE, code=reveal('{{chunk_name}}', {{idx_lines}})}", "```", "]]", ".column[.content.center[", "```{r output{{idx_lines}}, echo=FALSE, code=reveal('{{chunk_name}}', {{idx_lines}})}", "```", "]]", .open = "{{", .close = "}}", .sep = "\n" ) glue::glue_collapse(partial_knit_steps, "\n---\n") } ``` ```{r complete, eval=F, echo=F} ggplot(iris) + aes(Sepal.Length, Sepal.Width) + geom_point() + labs(x = "Sepal Length") + labs(y = "Sepal Width") + labs(title="The famous iris data") + labs(subtitle="Data collected by Anderson, Edgar (1935)") + aes(color= Species) + theme_bw(base_size=16) ``` `r paste(knitr::knit(text = partial_knit_chunks("complete")), collapse = "\n")` <!-- This css chunk can't be before the first class: split-40... lines --> ```{css, eval=TRUE} .remark-code{ line-height: 2; } ``` ```` ]] .item[ <iframe src="ggplot-tutorial.html" height="320" width="550"></iframe> ]] --- # <i class="fas fa-book"></i> Bibiliography and citations See [here](https://github.com/yihui/xaringan/wiki/Bibliography-and-citations) for using bibtex citation in `xaringan` slides. <br> ## References <a name=bib-tidyverse></a>[[1]](#cite-tidyverse) H. Wickham, M. Averick, J. Bryan, et al. "Welcome to the tidyverse". In: _Journal of Open Source Software_ 4.43 (2019), p. 1686. DOI: [10.21105/joss.01686](https://doi.org/10.21105%2Fjoss.01686). <a name=bib-xaringan></a>[[2]](#cite-xaringan) Y. Xie. _xaringan: Presentation Ninja_. R package version 0.16. 2020. URL: [https://CRAN.R-project.org/package=xaringan](https://CRAN.R-project.org/package=xaringan). --- background-image: url(images/bg1.jpg) background-size: cover class: hide-slide-number hide-footer <div style="position: absolute; left: 30%; top: 15%; width:47%;font-size:18pt"> <br> <h1 class="monash-blue" style="font-size:24pt!important"><i class="fas fa-link"></i> <a href="">emitanaka.org/slides/rladiesSSA2020</a></h1> Where to get help? <ul> <li>Your local R-Ladies Meetup: <a href="https://www.meetup.com/en-AU/rladies-melbourne/">Melbourne</a>, <a href="https://www.meetup.com/rladies-sydney/">Sydney</a>, <a href="https://www.meetup.com/rladies-canberra/">Canberra</a>, <a href="https://www.meetup.com/en-AU/rladies-perth/">Perth</a>, <a href="https://www.meetup.com/en-AU/rladies-adelaide/">Adelaide</a>, <a href="https://www.meetup.com/en-AU/rladies-brisbane/">Brisbane</a></li> <li><a href="https://www.rfordatasci.com/">R4DS Community Slack</a></li> <li><a href="https://twitter.com/search?q=%23rstats">Twitter with hastag #rstats</a></li> <li><a href="https://community.rstudio.com/">RStudio Community</a></li> <li><a href="https://stackoverflow.com/questions/tagged/r">Stackoverflow</a> (I answer questions tagged with `xaringan` often)</li> </ul> We teach <a href="https://handbook.monash.edu/2020/units/ETC5523">Communicating with Data</a> in the <a href="https://www.monash.edu/business/master-of-business-analytics">Masters of Business Analytics</a> at Monash University </div> .bottom_abs.width100.shade_black[ <img src="images/monash-logo.png" style="float:right;" height = "120px"/> **Emi Tanaka** Department of Econometrics and Business Statistics
<i class="fas fa-envelope faa-float animated "></i>
emi.tanaka@monash.edu
<i class="fab fa-twitter faa-float animated "></i>
@statsgen 30th Jun 2020 @ SSA NSW/Canberra x R-Ladies Sydney/Canberra | via Zoom ]