+ - 0:00:00
Notes for current slide
Notes for next slide

R Markdown

Rfun - An R Learning Series

John Little

2020-03-10

1 / 14

Rfun: An R Learning Event

Part of the
Data & Visualization Services Workshop Series

 

2 / 14

Simplified Markup Language

  • Structure Document for style and citations

  • Literate Code

    • Code Chunks
    • Inline Code + Prose
    • Multiple Code Langugages
  • Render in many formats

Output Formats

  • Slides (PowerPoint, xaringan, reveal, Beamer, Slidy, idoslides...)
  • Interactive Documents (HTML Widgets)
  • R Notebooks
  • Web Sites (blogdown & WebSites
  • Dashboards
  • MS Word Documents
  • E-books (bookdown, ePUB, Kindle)
  • HTML documents
  • GitHub documents
  • RTF / ODT
  • PDF Documents
  • Latex (ctex)
  • Journal article templates (e.g. elsevier journals)
  • CV
  • Package Vignettes
  • More
3 / 14
4 / 14

R Markdown in a nutshell

## Sub-heading
### Another deeper heading
Text attributes
*italic*, **bold**, `monospace`.
A [link](https://example.com).
Bullet list:
- apples
- oranges
- pears
Numbered list:
1. apples
2. oranges
3. pears

Sub-heading

Another deeper heading

italicized, bold, monospace

A link

Bullet list:

  • applies
  • oranges
  • pears

Numbered list:

  1. apples
  2. oranges
  3. pears
5 / 14

YAML Header

The YAML metadata affects the output of the rendered output.

---
title: "R Notebook"
subtitle: "Levering systemic power and smiling about it"
author: "Wendy Byrde"
date: "2018-09-28"
abstract: "<i>Summary of my document.</i><p>"
output: html_notebook
---
6 / 14

But, Why R Markdown?

8 / 14

Integration of R code chunks

Easy to read & write

Plain text is more sustainable1 over time

Multiple ouput formats

9 / 14

Excercise 1

In RStudio, Open an R Notebook (File > R Notebook) and practice marking up your prose with at least three of the markdown elements below

Style Markdown Syntax
bold **bold**
italics *italics*
images ![alt text](path/to/image)
web links [Google](https://google.com)
ordered and unordered lists cheetsheet - https://is.gd/rmarkdown
tables cheetsheet - https://is.gd/rmarkdown
blockquotes cheetsheet - https://is.gd/rmarkdown
footnote My text to note^[my footnote]
10 / 14

Excercise 2

Literate Code: R Markdown with R code chunks

In the same R Notebook add at least one of the markdown elements below

Element / Documentation Note
Code Chunks Ctrl + Alt + I (OS X: Cmd + Option + I)
e.g. plot(cars)
Inline Code Insert code into prose:
e.g. `r length(cars$speed)`
LaTex Equations bind LaTex within $
i.e. $ equation $
e.g. $\bar{X}=\frac{1}{n}\sum_{i=1}^nX_i$
Chunk Options There are a lot of options. Try setting image size within the code chunk settings.
YAML Metadata and output options

 

 

 

 

`

11 / 14

Exercise 3

Choose an output format below and "get started" learning a new R Markdown output option

Output Style Instructions Resources
Slide Deck Get Started DukeSlides (A xaringan implementation)
MS Word Get Started Use knitr::kable(df) for dataframe printing
Dashboard Get Started flexdashboard
Website Get Started Blogdown
PDF
 
 
Get Started
 
 
May need to install https://yihui.name/tinytex/
install.packages('tinytex')
tinytex::install_tinytex()
Book
 
   
 
Get Started
 
   
 
Bookdown
May need to install https://yihui.name/tinytex/
install.packages('tinytex')
tinytex::install_tinytex()
12 / 14

John Little

 

Rfun host...

You can make Rfun with our resources for R and data science analytics. See the R we having fun yet‽ resource pages.

Duke University

Data & Visualization Services

13 / 14

Shareable

Data, presentation, and handouts

C bn

CC BY-NC license

14 / 14

Rfun: An R Learning Event

Part of the
Data & Visualization Services Workshop Series

 

2 / 14
Paused

Help

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