RMarkdown

Outline

Review

Motivation

Markdown

RMarkdown

{review}

RESTful APIs

Representational State Transfer APIs

Exposes data components

Transfer data with HTTP (typically)

Facilitates web-queries of content

How it works

Navigate to a URL

Return information (JavaScript Object Notation)

https://api.spotify.com/v1/search?q=adele&type=artist
{
    artists: {
        href: "https://api.spotify.com/v1/searc...",
        items: [{
            external_urls: {
            spotify: "https://open.spotify...."
        },
        followers: {
            href: null,
            total: 4093432
        },
    }
}

Today's API

{exercise 1}

{motivation}

Summary of Results

How many numbers are there in this summary?

In any paper...

Hundreds of values

Dozens of graphics

What do you do?

ctrl + c

ctrl + v

ctrl + v

ctrl + v

ctrl + v

What do you do?

RMarkdown

Dynamically generate documents

Integrate code and reporting

Include results in text

Incorporate graphics

{markdown review}

Markdown

# Markdown Description
Allows you to apply simple syntax to create 
well formatted documents, including the ability to:

- Make text **bold**, *italicized*, or `monospace`
- Have headers
- Create lists
	1.  Ordered lists
	2. Or unordered lists 

{exercise 2}

credit: Yihui Xie, Rstudio

Getting Started

Getting Started

Write some Markdown + R code

This is the code we will look 
at in class.  This is just 
plain  old Markdown that 
lets you render text in
**bold** or _italics_.
However, we can put in a
chunk or R code, and it
will show us the code 
and results!

```{r}
# Write R code in here
# It's wrapped in three ```
x <- runif(1:100)
hist(x)
```

Click Knit HTML

file.Rmd
file.html

Show results and code

This is the code we will look 
at in class.  This is just 
plain  old Markdown that 
lets you render text in
**bold** or _italics_.
However, we can put in a
chunk or R code, and it
will show us the code 
and results!

```{r}
x <- runif(1:100)
hist(x)
```

Show code without results

This is the code we will look 
at in class.  This is just 
plain  old Markdown that 
lets you render text in
**bold** or _italics_.
However, we can put in a
chunk or R code, and it
will show us the code 
and results!

```{r, eval=FALSE}
x <- runif(1:100)
hist(x)
```
(It did not show the plot)
eval=FALSE

Show results without code

This is the code we will look 
at in class.  This is just 
plain  old Markdown that 
lets you render text in
**bold** or _italics_.
However, we can put in a
chunk or R code, and it
will show us the code 
and results!

```{r, echo=FALSE}
x <- runif(1:100)
hist(x)
```
(It did not show the **code**)
echo=FALSE

Code Chunks

Hide results (i.e., don't evaluate code)

Hide code (i.e., don't echo it)

Hide warnings

Hide messages (hint, hint)

```{r, eval=FALSE}
# R code goes here
```
```{r, echo=FALSE}
# R code goes here
```
```{r, warning=FALSE}
# R code goes here
```
```{r, message=FALSE}
# R code goes here
```

In-line Code

Reference R variables/values within Markdown text!

# Markdown text
I wrote some markdown text, then did some analysis:
```{r}
scores <- runif(100, 50, 100)
avg <- mean(scores)
```
Then I wanted to tell you that the average was `r avg` across
 `r length(scores)` tests.

{exercise 3}

Resources

RMarkdown website

RMarkdown cheatsheet

RMarkdown book!

Assignments

Assignment-5: Github Report (due Wed. 2/10)

Made with Slides.com