####Families in 2022###
family_count_2022 <- sd_clean %>%
filter(year == "2022") %>%
group_by(family) %>%
summarize(n = sum(n, na.rm = T))
###How many individuals###
unique_fish_bk_2022 <- sd_clean %>%
filter(fish_spp == "bk",
year == "2022") %>%
group_by(sample) %>%
summarize(
id = first(id),
sample = first(sample),
total_count = sum(`n`, na.rm = TRUE),
tail_length = first(fish_tl_mm),
digestion_code = first(digestion_code),
.groups = "drop"
)
unique_fish_lct_2025 <- sd_clean %>%
filter(fish_spp == "lct",
year == "2025") %>%
group_by(sample) %>%
summarize(
id = first(id),
sample = first(sample),
total_count = sum(`n`, na.rm = TRUE),
tail_length = first(fish_tl_mm),
digestion_code = first(digestion_code),
.groups = "drop"
)
unique_fish_lct_2022 <- sd_clean %>%
filter(fish_spp == "lct",
year == "2022") %>%
group_by(id) %>%
summarize(
id = first(id),
sample = first(sample),
total_count = sum(`n`, na.rm = TRUE),
tail_length = first(fish_tl_mm),
year = first(year),
digestion_code = first(digestion_code),
.groups = "drop"
)
###All Unique Fish in One Place###
unique_fish <- sd_clean %>%
group_by(id) %>%
filter(fish_spp %in% c('lct', 'bk')) %>%
summarize(
id = first(id),
total_count = sum(`n`, na.rm = TRUE),
fish_spp = first(fish_spp),
tail_length = first(fish_tl_mm),
year = first(year),
digestion_code = first(digestion_code),
grams = first(grams),
.groups = "drop"
)
unique_fish_lct <- sd_clean %>%
filter(fish_spp == "lct") %>%
group_by(id) %>%
summarize(
id = first(id),
total_count = sum(`n`, na.rm = TRUE),
tail_length = first(fish_tl_mm),
year = first(year),
digestion_code = first(digestion_code),
.groups = "drop"
)
###How do Total counts vary across year###
ggplot(unique_fish_lct, aes(x = as.factor(year), y = total_count)) +
geom_boxplot(fill = "lightblue", outlier.shape = NA) + # boxplot
geom_jitter(width = 0.2, size = 2, color = "darkblue", alpha = 0.7) + # individual points
labs(
title = "Total Count Inverts by Year for LCT",
x = "Year",
y = "Total Count Inverts"
) +
theme_bw() +
theme(
plot.title = element_text(face = "bold", size = 14),
axis.text = element_text(size = 12),
axis.title = element_text(size = 13)
)