Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal of a stat_prop() #66

Open
larmarange opened this issue Feb 2, 2020 · 0 comments
Open

Proposal of a stat_prop() #66

larmarange opened this issue Feb 2, 2020 · 0 comments

Comments

@larmarange
Copy link
Contributor

larmarange commented Feb 2, 2020

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

image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant