Literate programming

Getting started

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()) %>%
  filter(species_id %in% c('DM', 'DO', 'DS')) %>%
  na.omit()

head(time_series)
```

## Plot the time-series.

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

Notebook

Citations

bibliography: bibliography.bib
[@white2018]

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()
```