• Copy and paste the example broken script into R

Basic Manual Debugging Strategy

Example

  • Creat a file with the following code in it
  • Run it
  • Work through debugging the code
library(dplyr)
library(ggplot)

surveys <- read.csv('https://ndownloader.figshare.com/files/2292172')

do_counts_by_year <- surveys %>%
  filter(species == "DO") %>%
  group_by(year)
  summarize(count = n())

ggplot(do_counts_by_year, aes(x = year, y = count)) +
  geom_point() +
  geom_line() +
  labels(x = "Year", y = "Count")

Debugged version of example

library(dplyr)
library(ggplot2)

surveys <- read.csv('https://ndownloader.figshare.com/files/2292172')

do_counts_by_year <- surveys %>%
  filter(species_id == "DO") %>%
  group_by(year) %>%
  summarize(count = n())

ggplot(do_counts_by_year, aes(x = year, y = count)) +
  geom_point() +
  geom_line() +
  labs(x = "Year", y = "Count")