Press the right arrow to progress to the next slide!
Emi Tanaka
Department of Econometrics and Business Statistics
emi.tanaka@monash.edu @statsgen
30th Jun 2020 @ SSA NSW/Canberra x R-Ladies Sydney/Canberra | via Zoom
xaringan
R-package 📦
This talk is NOT about:
how to present well or communicate
This talk is NOT about:
how to present well or communicate
how to design your slides
🎯
Learn about Beamer R Markdown
Why care about R Markdown?
🎯
Learn about Beamer R Markdown
Why care about R Markdown?
Get started with xaringan
= R Markdown remark.js
HTML/CSS/JS
🎯
Learn about Beamer R Markdown
Why care about R Markdown?
Get started with xaringan
= R Markdown remark.js
HTML/CSS/JS
Why HTML slides?
🎯
Learn about Beamer R Markdown
Why care about R Markdown?
Get started with xaringan
= R Markdown remark.js
HTML/CSS/JS
Why HTML slides?
Questions? Do ask away! 👩🏻💻
example-beamer-clean.tex
\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}## TitleContent\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::: columnColumn 1 content:::::: columnColumn 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}\pauseYou can also include pauses with \texttt{.\ .\ .}\end{frame}\end{document}
example-beamer-clean.pdf
example-beamer-clean.tex
\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}## TitleContent\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::: columnColumn 1 content:::::: columnColumn 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}\pauseYou can also include pauses with \texttt{.\ .\ .}\end{frame}\end{document}
example-beamer.Rmd
---title: This is a Beamer presentation made using R Markdownsubtitle: "`rmarkdown::beamer_presentation`"author: Emi Tanakainstitute: Monash Universitydate: "30th June 2020"fontsize: 10ptmathspec: true # for metropolis themeaspectratio: 169 # 16:9#classoption: handoutoutput: 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.texheader-includes: - \usepackage{fancyvrb}---
# 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 usualConsider 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::: columnInstead of ::: block### \LaTeX```\begin{frame}{Title}Content\ end{frame}```:::do### markdown```## TitleContent```:::::: columnIn 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 outputStick 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::: columnColumn 1 content:::::: columnColumn 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)})```
example-beamer
.Rmd
---title: This is a Beamer presentation made using R Markdownsubtitle: "`rmarkdown::beamer_presentation`"author: Emi Tanakainstitute: Monash Universitydate: "30th June 2020"fontsize: 10ptmathspec: true # for metropolis themeaspectratio: 169 # 16:9#classoption: handoutoutput: 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.texheader-includes: - \usepackage{fancyvrb}---
# 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 usualConsider 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::: columnInstead of ::: block### \LaTeX```\begin{frame}{Title}Content\ end{frame}```:::do### markdown```## TitleContent```:::::: columnIn 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 outputStick 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::: columnColumn 1 content:::::: columnColumn 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)})```
example-beamer.pdf
Clean syntax for writing content
Integrates code and output easily:
Some code syntax highlighting code done for you
Verbatim code
mtcars %>% mutate(new = 30, string = "hello")
Syntax highlighting
mtcars %>% mutate(new = 30, string = "hello")
(achieved commonly using listings
package in LaTeX)
example-beamer2.Rmd
---title: The Power of R Markdownsubtitle: "`rmarkdown::beamer_presentation`"author: Emi Tanakainstitute: Monash Universitydate: "30th June 2020"fontsize: 10ptmathspec: true # for metropolis themeaspectratio: 169 # 16:9#classoption: handoutoutput: 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.texheader-includes: - \usepackage{fancyvrb} - \usepackage{graphicx}---
# Power of R Markdown## Example: my fancy graphBehold! 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 demonstrationThis 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)})```
example-beamer2.pdf
xaringan
slidesinstall.packages("xaringan")
RStudio > File > New File > R Markdown > From Template > Ninja Presentation
xaringan
slidesinstall.packages("xaringan")
RStudio > File > New File > R Markdown > From Template > Ninja Presentation
install.packages("xaringanthemer")
RStudio > File > New File > R Markdown > From Template > Ninja Themed Presentation
Interactivity! Animate!
DT::datatable(mtcars)
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | |
---|---|---|---|---|---|---|---|---|---|---|---|
Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 | 0 | 1 | 4 | 4 |
Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 | 0 | 1 | 4 | 4 |
Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.32 | 18.61 | 1 | 1 | 4 | 1 |
Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 |
Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.44 | 17.02 | 0 | 0 | 3 | 2 |
Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.46 | 20.22 | 1 | 0 | 3 | 1 |
Duster 360 | 14.3 | 8 | 360 | 245 | 3.21 | 3.57 | 15.84 | 0 | 0 | 3 | 4 |
Merc 240D | 24.4 | 4 | 146.7 | 62 | 3.69 | 3.19 | 20 | 1 | 0 | 4 | 2 |
Merc 230 | 22.8 | 4 | 140.8 | 95 | 3.92 | 3.15 | 22.9 | 1 | 0 | 4 | 2 |
Merc 280 | 19.2 | 6 | 167.6 | 123 | 3.92 | 3.44 | 18.3 | 1 | 0 | 4 | 4 |
library(plotly) # for interactive plotsg <- 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).
<iframe src="example-plotly.html" width="550" height="500"></iframe>
flipbooks
talk by Gina Reynolds and her flipbookr
R-package.---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---
```{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; }```
See here for using bibtex citation in xaringan
slides.
[1] 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.
[2] Y. Xie. xaringan: Presentation Ninja. R package version 0.16. 2020. URL: https://CRAN.R-project.org/package=xaringan.
Emi Tanaka
Department of Econometrics and Business Statistics
emi.tanaka@monash.edu @statsgen
30th Jun 2020 @ SSA NSW/Canberra x R-Ladies Sydney/Canberra | via Zoom
Emi Tanaka
Department of Econometrics and Business Statistics
emi.tanaka@monash.edu @statsgen
30th Jun 2020 @ SSA NSW/Canberra x R-Ladies Sydney/Canberra | via Zoom
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 |