An R
user who would like to share awesome things in R
An R
user who would like to share awesome things in R
by showing a bunch of R code snippets
without losing taste.
An R
user who would like to share awesome things in R
by showing a bunch of R code snippets
without losing taste.
given no time nor money on formatting codes and adjusting layouts.
Beautiful and concise layout
Code highlighting and live demos
Version control and easy distribution
It animates
Do you use ctrl + K
to render your slides?
Do you use ctrl + K
to render your slides?
Moon Reader
from either the pacakge or the addinssave
itPress h
or ?
Press h
or ?
m
-> mirror
b
-> blackout
f
-> fullscreen mode
Press h
or ?
m
-> mirror
b
-> blackout
f
-> fullscreen mode
c
-> clone slideshow
p
-> presenter mode
t
-> restart timer
names(xaringan:::list_css())
## [1] "chocolate-fonts" "chocolate" "default-fonts" ## [4] "default" "duke-blue" "fc-fonts" ## [7] "fc" "hygge-duke" "hygge" ## [10] "kunoichi" "lucy-fonts" "lucy" ## [13] "metropolis-fonts" "metropolis" "middlebury-fonts"## [16] "middlebury" "ninjutsu" "rladies-fonts" ## [19] "rladies" "robot-fonts" "robot" ## [22] "rutgers-fonts" "rutgers" "shinobi" ## [25] "tamu-fonts" "tamu" "uo-fonts" ## [28] "uo" "uol-fonts" "uol"
names(xaringan:::list_css())
## [1] "chocolate-fonts" "chocolate" "default-fonts" ## [4] "default" "duke-blue" "fc-fonts" ## [7] "fc" "hygge-duke" "hygge" ## [10] "kunoichi" "lucy-fonts" "lucy" ## [13] "metropolis-fonts" "metropolis" "middlebury-fonts"## [16] "middlebury" "ninjutsu" "rladies-fonts" ## [19] "rladies" "robot-fonts" "robot" ## [22] "rutgers-fonts" "rutgers" "shinobi" ## [25] "tamu-fonts" "tamu" "uo-fonts" ## [28] "uo" "uol-fonts" "uol"
These go to your YAML
output: xaringan::moon_reader: css: [default, rladies, rladies-fonts]
Add my-style.css
to the YAML with the current css file
output: xaringan::moon_reader: css: [default, rladies, lucy-fonts, my-style.css]
Add my-style.css
to the YAML with the current css file
output: xaringan::moon_reader: css: [default, rladies, lucy-fonts, my-style.css]
While sitting in my-style.css file,
.red { color: red; }.remark-code-line-highlighted { background-color: #e8c9e9; }.remark-code, .remark-inline-code { color: #7c347f; font-weight: 300;}
Add my-style.css
to the YAML with the current css file
output: xaringan::moon_reader: css: [default, rladies, lucy-fonts, my-style.css]
While sitting in my-style.css file,
.red { color: red; }.remark-code-line-highlighted { background-color: #e8c9e9; }.remark-code, .remark-inline-code { color: #7c347f; font-weight: 300;}
I've changed it to red.
You can find CSS files here. However, don't save your own CSS file here.
You can find CSS files here. However, don't save your own CSS file here.
It converts PowerPoint slides to xaringan slides
---title: "How to Make Slides in R"output: xaringan::moon_reader---
---title: "How to Make Slides in R"output: xaringan::moon_reader---
---title: "How to Make Slides in R"subtitle: "Using xaringan"author: "Zhi Yang"date: "2019/2/26"output: xaringan::moon_reader: css: ["default", "rladies", "lucy-fonts", "my-style.css"] lib_dir: libs nature: highlightStyle: github highlightLines: true countIncrementalSlides: false #chakra: "remark.js" ---
Three dashes ---
gives a new slide
---title: "How to Make Slides in R"output: xaringan::moon_reader---A slide---Another slide
left,center, right
top,middle, bottom
---class: center, middle # Demo slideThis is a center- and middle- aligned slide.
.left[texts].center[texts] .right[texts]
---class: center, middle # Demo slide.right[This is a center- and middle- aligned slide.]
This is a center- and middle- aligned slide.
# HiDid you know--you can--do this?
# HiDid you know--you can--do this?
Did you know
# HiDid you know--you can--do this?
Did you know
you can
# HiDid you know--you can--do this?
Did you know
you can
do this?
use the trailing comment #<<
to highlight specific lines of the code
Source:
```{r}namedata <- babynames %>% filter(name == "Orange") %>% filter(sex == "M") %>% #<< arrange(year)head(namedata) ```
Output:
namedata <- babynames %>% filter(name == "Orange") %>% filter(sex == "M") %>% arrange(year)head(namedata)
use the chunk option highlight.output
to highlight specific lines of the text output
Source:
```{r head, highlight.output=c(1, 3)}namedata <- babynames %>% filter(name == "Orange") %>% filter(sex == "M") %>% #<< arrange(year)head(namedata) ```
Output:
## # A tibble: 6 x 5## year sex name n prop## <dbl> <chr> <chr> <int> <dbl>## 1 1881 M Orange 9 0.0000831## 2 1882 M Orange 8 0.0000656## 3 1883 M Orange 11 0.0000978## 4 1884 M Orange 13 0.000106 ## 5 1885 M Orange 8 0.000069 ## 6 1886 M Orange 7 0.0000588
.pull-left[```{r refname echo=TRUE, eval=FALSE}your R code ```].pull-right[```{r ref.label="refname" echo=FALSE, eval=TRUE}```]
.pull-left
and .pull-right
provide 47% width
.pull-left[```{r refname echo=TRUE, eval=FALSE}your R code ```].pull-right[```{r ref.label="refname" echo=FALSE, eval=TRUE}```]
.pull-left
and .pull-right
provide 47% width
namedata <- babynames %>% filter(name == "Orange") %>% filter(sex == "M") %>% arrange(year)head(namedata)
.pull-left[```{r refname echo=TRUE, eval=FALSE}your R code ```].pull-right[```{r ref.label="refname" echo=FALSE, eval=TRUE}```]
.pull-left
and .pull-right
provide 47% width
namedata <- babynames %>% filter(name == "Orange") %>% filter(sex == "M") %>% arrange(year)head(namedata)
## # A tibble: 6 x 5## year sex name n prop## <dbl> <chr> <chr> <int> <dbl>## 1 1881 M Orange 9 0.0000831## 2 1882 M Orange 8 0.0000656## 3 1883 M Orange 11 0.0000978## 4 1884 M Orange 13 0.000106 ## 5 1885 M Orange 8 0.000069 ## 6 1886 M Orange 7 0.0000588
.left-column[```{r evel = FALSE}Your R code```].right-column[```{r evel = FALSE, echo = FALSE}Your R code```]
.left-column
and .right-column
provide 20% and 75% width
.left-column[```{r evel = FALSE}Your R code```].right-column[```{r evel = FALSE, echo = FALSE}Your R code```]
.left-column
and .right-column
provide 20% and 75% width
head(gss_cat)
.left-column[```{r evel = FALSE}Your R code```].right-column[```{r evel = FALSE, echo = FALSE}Your R code```]
.left-column
and .right-column
provide 20% and 75% width
head(gss_cat)
## # A tibble: 6 x 9## year marital age race rincome partyid relig denom tvhours## <int> <fct> <int> <fct> <fct> <fct> <fct> <fct> <int>## 1 2000 Never ma~ 26 White $8000 to~ Ind,near ~ Protest~ Southe~ 12## 2 2000 Divorced 48 White $8000 to~ Not str r~ Protest~ Baptis~ NA## 3 2000 Widowed 67 White Not appl~ Independe~ Protest~ No den~ 2## 4 2000 Never ma~ 39 White Not appl~ Ind,near ~ Orthodo~ Not ap~ 4## 5 2000 Divorced 25 White Not appl~ Not str d~ None Not ap~ 1## 6 2000 Married 25 White $20000 -~ Strong de~ Protest~ Southe~ NA
head(iris, n = 3)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species## 1 5.1 3.5 1.4 0.2 setosa## 2 4.9 3.0 1.4 0.2 setosa## 3 4.7 3.2 1.3 0.2 setosa
knitr::kable(head(iris, n = 3), format = "html")
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
Set the table to be the HTML
format
par(mar = c(4, 4, 1, 0.1))plot(cars, pch = 19, col = "darkgray", las = 1)
use fig.height
and fig.width
to control the size

Should it be something like {width=10px}
? 😢
Should it be something like {width=10px}
? 😢
Option 1:
<img src="imgs/ocrug.jpeg" width="20%" />
Should it be something like {width=10px}
? 😢
Option 1:
<img src="imgs/ocrug.jpeg" width="20%" />
Option 2:
```{r out.width = "20%", eval=TRUE}knitr::include_graphics("imgs/ocrug.jpeg")```
background-image: url(/imgs/ocrug.jpeg)background-size: cover
background-image: url(/imgs/ocrug.jpeg)background-size: contain
background-image: url(/imgs/ocrug.jpeg)background-size: containbackground-position: bottom
background-image: url(https://secure.meetupstatic.com/photos/event/2/b/9/e/600_471491166.jpeg)background-size: containbackground-position: bottom
background-image: url(imgs/ocrug_logo.png), url(imgs/ocrug_logo.png)background-position: 0% 100%, 100% 0%background-size: 30%, 10%
Step 1:
go to netlify.com
Step 2:
connect with your Github account
Step 3:
select a repo
Step 3:
select a repo
Step 4:
select a branch
Step 5:
deploy a site
Step 6:
change site name
@zhiiiyang
https://github.com/zhiiiyang/XaringanTutorial
Slides created via the R package xaringan
Template created by Alison Hill
An R
user who would like to share awesome things in R
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 |