I am trying to add total count (n) to each bar on my ggplot bar graph. Can anyone help?
Thanks.
mydf_tmp <- mydf %>%
group_by() %>%
summarise(Giant.Remora = sum(Giant.Remora),
Sharksucker.Remora = sum(Sharksucker.Remora),
Juvenile.Remora = sum(Juvenile.Remora),
Black.Trevally = sum(Black.Trevally),
Pilot.Fish = sum(Pilot.Fish)) %>% data.frame()
plot_data <- data.frame(Species = names(mydf_tmp),
Total = as.numeric(as.character(mydf_tmp[1,])))
ggplot(data = plot_data) +
geom_bar(mapping=aes(x = Species, y = Total),
stat = "identity", show.legend = FALSE) +
theme_gray(base_size = 14) +
labs(x = ~italic(M.birostris) ~ "Hitchhiker Species") +
labs(y = 'Total Presence') +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, size = 14))