Intermediate variables

surveys_DS <- filter(surveys, species_id == "DS", !is.na(weight))
surveys_DS_by_yr <- group_by(surveys_DS, year)
avg_weight_DS_by_yr <- summarize(surveys_DS_by_yr,
                                 avg_weight = mean(weight))

Do Portal Data Manipulation Exercise 1-2

Pipes

surveys %>%
  filter(species_id == "DS", !is.na(weight))
avg_weight_DS_by_yr <- surveys %>%
  filter(species_id == "DS", !is.na(weight)) %>%
  group_by(year) %>%
  summarize(avg_weight = mean(weight))

Modify your answer to Task 2 in Portal Data Manipulation to use pipes.