Literate programming

Getting started

install.packages(c("rmarkdown", "knitr", "tinytex"))
tinytex::install_tinytex()

Markdown


## Concept

Exploration of population dynamic patterns at **The Portal Project**.
How do counts of rodents like *Dipodomys* species change through time?

In this document I will:

1. Load data from the [Portal Project Teaching Database](http://figshare.com/articles/Portal_Project_Teaching_Database/1314459)
2. Process it into population time series
3. And make initial visualizations

R chunks


## Required Packages

```{r}
library(dplyr)
library(ggplot2)
```

## Data

```{r}
data <- read.csv("https://ndownloader.figshare.com/files/2292172")
head(data)
```

Chunk options


```{r, message=FALSE}
library(dplyr)
library(ggplot2)
```

```{r, cache=TRUE}
data <- read.csv("https://ndownloader.figshare.com/files/2292172")
head(data)
```
The data includes `r length(unique(data$species_id))` species.

Analysis Example


## Analysis

Get the time-series of counts for all species.
          
```{r}
time_series <-
  data %>%
  group_by(species_id, year) %>%
  summarize(count = n())
head(time_series)
```

## Plot the time-series.

```{r, message=FALSE, echo=FALSE, cache=TRUE}
ggplot(time_series, aes(x = year, y = count)) +
  geom_line() +
  facet_wrap(~species_id)
```

Citations

bibliography: bibliography.bib
[@white2018]

Notebook

R Presentations


Untitled
========================================================
author: Ethan P. White
date: 
autosize: true


Outline
========================================================

- Show making slides in R
- Include code on slides
- Includes graphs on slides

Slide With Code
========================================================

```{r}
data <- read.csv("https://ndownloader.figshare.com/files/2292172")
```

Histogram of Masses
========================================================


```{r, echo = FALSE}
library(ggplot2)
ggplot(data, aes(x = weight, color = species_id)) +
geom_histogram()
```