Long time fan of this site, first time user though. Been searching for a similar/working result for this question. I am trying to show the PROPORTION that each level of a 2 level factor appear at three locations. All in a side by side bar chart in ggplot.
Here is the code I've been using to (try) to create the chart. The result has been two charts: one using geom_bar and geom_col, respectively. What I'd like is essentially a combination of the two. The first, but with the colors and Y axis of the second.
Thank you!
ggplot(df,aes(x = Stream,fill = death)) +
geom_bar(position = "dodge")+
scale_fill_manual(values = c(rep(c("gray45", "gray75"))))+
labs(fill="Time of Death")
death_stream <-df %>%
group_by(Stream,Tree_Death)%>%
summarise (n = n()) %>%
mutate(rel.freq = paste0(round(100 * n/sum(n), 0), "%"))
death_stream %>%
ggplot(aes(x = Stream,y = rel.freq)) +
geom_col(position = "dodge",fill = "grey50", colour = "black")+
labs(fill="Time of Death")