plot <- fish |>
group_by(year, section, trip) |>
summarize(missing_count = sum(is.na(weight)), .groups = "drop") |>
mutate(trip = case_when(
trip == 1 ~ "Trip 1",
trip == 2 ~ "Trip 2")) |>
ggplot(aes(x = year, y = missing_count, color = section)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Set2") +
labs(
title = "Missing Fish Weights for Trout Species on the Blackfoot River",
x = "Year",
y = "",
color = "Section") +
facet_wrap(~ trip) +
theme_minimal()
annotate_text <- data.frame(year = c(1994, 1993),
missing_count = c(150, 40),
trip = factor(c("Trip 2", "Trip 2"),
levels = c("Trip 1","Trip 2"),
),
section = factor(c("Johnsrud", "ScottyBrown"),
levels = c("Johnsrud", "ScottyBrown"))
)
plot +
geom_text(data = annotate_text, label = c("Johnsrud", "ScottyBrown")) +
theme(legend.position = "none",
plot.title = element_text(size = 12),
axis.text.x = element_text(size = 12),
axis.text.y = element_text(size = 12),
axis.title = element_text(size = 12),
strip.text.x = element_text(size = 12)
)