Use the left and right arrow keys to navigate the presentation forward and backward respectively. You can also use the arrows at the bottom right of the screen to navigate with a mouse.
FAIR USE ACT DISCLAIMER: This site is for educational purposes only. This website may contain copyrighted material, the use of which has not been specifically authorized by the copyright holders. The material is made available on this website as a way to advance teaching, and copyright-protected materials are used to the extent necessary to make this class function in a distance learning environment. The Fair Use Copyright Disclaimer is under section 107 of the Copyright Act of 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, education and research.
knitr
which we have been using in activities to create a mixture of text and chunks of code. knitr
, chunks of code will be executed, and graphs or other results inserted into the final document.knitr
allows you to mix basically any sort of text with code from different programming languages, but we recommend that you use R Markdown
, which mixes Markdown with R. ---
title: "Initial R Markdown document"
author: "Jane Doe"
date: "April 23, 2015"
output: html_document
---
**bold**
, and you make things italics by using underscores, like this _italics_
.
<b>bold</b>
or <emph>italics</emph>
, where the Markdown equivalent usually simplifies the syntax. * bold with double-asterisks
* italics with underscores
* code-type font with backticks
- bold with double-asterisks
- italics with underscores
- code-type font with backticks
Each will appear as:
within their respective indentation levels.
You can make a numbered list by just using numbers. You can even use the same number over and over if you want:
1. bold with double-asterisks
1. italics with underscores
1. code-type font with backticks
You can make section headers of different sizes by initiating a line with some number of #
symbols:
# Title
## Main section
### Sub-section
#### Sub-sub section
You compile the R Markdown document to an html webpage by clicking the “Knit” button in the upper-left.
You can make a hyperlink like this:
[text to show](http://the-web-page.com)
.
You can include an image file like this: 
If you know how to write equations in LaTeX, you can use $ $
and $$ $$
to insert math equations, inline like $E = mc^2$
and in its own chunk by
$$y = \mu + \sum_{i=1}^p \beta_i x_i + \epsilon$$
When processed, the R code will be executed; if they produce figures, the figures will be inserted in the final document.
The main code chunks look like this:
```{r load_data} gapminder <- read.csv("gapminder.csv") ```
```{r chunk_name}
and ```
. When you press the “Knit” button, the R Markdown document is processed by knitr
and a plain Markdown document is produced (as well as, potentially, a set of figure files): the R code is executed and replaced by both the input and the output;
The Markdown and figure documents are then processed by the tool pandoc
, which converts the Markdown file into an html file, with the figures embedded.
There are a variety of options to affect how the code chunks are treated. Here are some examples:
echo=FALSE
to avoid having the code itself shown.results="hide"
to avoid having any results printed.eval=FALSE
to have the code shown but not evaluated.warning=FALSE
and message=FALSE
to hide any warnings or messages produced.fig.height
and fig.width
to control the size of the figures produced (in inches).So you might write:
```{r load_libraries, echo=FALSE, message=FALSE} library("dplyr") library("ggplot2") ```
```{r global_options, echo=FALSE} knitr::opts_chunk$set(fig.path="Figs/", message=FALSE, warning=FALSE, echo=FALSE, results="hide", fig.width=11) ```
fig.path
option defines where the figures will be saved. /
here is really important; without it, the figures would be saved in the standard place but just with names that begin with Figs
.fig.path
to define separate prefixes for the figure file names, like fig.path="Figs/cleaning-"
and fig.path="Figs/analysis-"
.`r
and `
for an in-line code chunk, like so:`r round(some_value, 2)`
.pdf_document
or word_document
in the initial header of the file.If required, this is detailed in an error message.