Intermediate variables

ds_data <- filter(surveys, species_id == "DS")
ds_data_by_year <- group_by(ds_data, year)
ds_weight_by_year <- summarize(ds_data_by_year,
                               avg_weight = mean(weight, na.rm = TRUE))

Do Portal Data Manipulation Exercise 1-2

Pipes

x = c(1, 2, 3)
mean(x)
x %>% mean()
x = c(1, 2, 3, NA)
mean(x, na.rm = TRUE)
x %>% mean(na.rm = TRUE)
surveys %>%
  filter(species_id == "DS", !is.na(weight))
ds_weight_by_year <- surveys %>%
  filter(species_id == "DS") %>%
  group_by(year) %>%
  summarize(avg_weight = mean(weight, na.rm = TRUE))

Do Portal Data Manipulation Pipes 1.