R Markdown is built into RStudio and allows you to create documents like HTML, PDF, and Word documents from R. With R Markdown, you can embed R code into your documents.
The beginning of an R Markdown file looks like this:
---
title: "Air Quality"
author: "JHU"
date: "May 17, 2016"
output: html_document
---
The new document you’ve created will contain
example text and code below this – delete it for a fresh start.
## Insert Title Here***### Subheading or #### Smaller Subheading## New Slide Title- bullet point+ sub-point1. first pointa) sub-sub-point>- iterated bullet point| Text | Code in R Markdown |
|---|---|
| plain text | plain text |
| italics | *italics* |
| bold | **bold** |
| link | [link](http://www.jhsph.edu) |
verbatim code |
code here |
This is a chunk of R code in R Markdown:
```{r}
head(airquality)
```
The code gets run, and both the input and output are displayed.
head(airquality)
## Ozone Solar.R Wind Temp Month Day
## 1 41 190 7.4 67 5 1
## 2 36 118 8.0 72 5 2
## 3 12 149 12.6 74 5 3
## 4 18 313 11.5 62 5 4
## 5 NA NA 14.3 56 5 5
## 6 28 NA 14.9 66 5 6
To hide the input code, use echo=FALSE.
```{r,
echo=FALSE}
head(airquality)
```
## Ozone Solar.R Wind Temp Month Day
## 1 41 190 7.4 67 5 1
## 2 36 118 8.0 72 5 2
## 3 12 149 12.6 74 5 3
## 4 18 313 11.5 62 5 4
## 5 NA NA 14.3 56 5 5
## 6 28 NA 14.9 66 5 6
This can be useful for showing plots.
To show the input code only, use eval=FALSE.
```{r, eval=FALSE}
head(airquality)
```
head(airquality)
To run the code without showing input or output, use
include=FALSE.
```{r, include=FALSE}
library(ggplot2)
```
output line in the header, or by selecting an output from
the Knit button’s pull-down menu.output: ioslides_presentationoutput: slidy_presentationoutput: beamer_presentationFor more information about R Markdown visit http://rmarkdown.rstudio.com/