I\'m trying to create a bar plot with ggplot2, showing counts on the y axis, but also the percents of total on top of each bar. I\'ve calculated the counts and percents of t
Just use percent as label.
percent
iris %>% group_by(Species) %>% summarize(count = n()) %>% mutate(percent = count/sum(count)) %>% ggplot(aes(x=Species, y=count)) + geom_col() + geom_text(aes(label = paste0(round(100 * percent, 1), "%")), vjust = -0.25)