Set up R console:

library(dplyr)
library(ggplot2)

surveys <- read.csv("surveys.csv")

ts_data <- surveys %>%
             group_by(species_id, year) %>%
             summarize(count = n(), biomass = sum(weight))

dm_ts_data <- filter(ts_data, species_id == "DM")
do_ts_data <- filter(ts_data, species_id == "DO")

Basics

ggplot(dm_ts_data, aes(x = year, y = count)) +
  geom_line()
ggplot(dm_ts_data, aes(x = year, y = count)) +
  geom_line() +
  scale_y_log10()
ggplot(dm_ts_data, aes(x = year, y = count)) +
  geom_line(size = 1, color = "red") +Population
  scale_y_log10() +
  xlab("Year") +
  ylab("Number of Individuals") +
  ggtitle("Dipodomys Merriami Time-Series at Portal") +
  theme_bw()

Do Exercise 2 - Mass vs Metabolism.

Grouping

ggplot(ts_data, aes(x = year, y = count, color = species_id)) +
  geom_line()
ggplot(ts_data, aes(x = year, y = count)) +
  geom_line() +
  facet_wrap(~species_id)

Do Tasks 1-4 in Exercise 3 - Adult vs Newborn Size.

Layers

ggplot(ts_data, aes(x = year, y = count)) +
  geom_line() +
  geom_point() +
  geom_smooth(method = "lm") +
  facet_wrap(~species_id)
ggplot(dm_ts_data, aes(x = year, y = count)) +
  geom_line() +
  geom_line(data = do_ts_data, aes(x = year, y = count), 
	color = "red")

Do Task 5 in Exercise 3 - Adult vs Newborn Size.

Statistical transformations

surveys <- read.csv("surveys.csv")
surveys <- filter(surveys, weight > 0)
ggplot(surveys, aes(x = species_id))
  + geom_bar()
ggplot(surveys, aes(x = weight)) +
  geom_histogram()
ggplot(surveys, aes(x = weight, fill = species_id)) +
  geom_histogram() +
  scale_x_log10() +
  facet_wrap(~plot_id) +
  xlab("Mass (g)") +
  ylab("Number of Individuals") +
  theme_bw(base_size = 16)

Additional information