ggalt
ggalt copied to clipboard
Proposal of a stat_prop()
I have developed a new stat for ggplot2
allowing to compute proportions according to a specified denominator.
For example, it allows to compute and to display column proportion on a bar chart with position = fill
.
ggplot(as.data.frame(Titanic)) +
aes(x = Class, fill = Survived, weight = Freq) +
geom_bar(position = "fill") +
geom_text(aes(by = Class), stat = "prop", position = position_fill(.5))
will produce
Current code is visible here: https://github.com/larmarange/JLutils/blob/master/R/stat_prop.R
Do you think that such stat could be a good addition for ggalt
? Or is it out of the scope of your package?
Best regards