1

Inspired by this question

Apparantly, there is some of way to calculate groupwise percentages in histograms using special variables like "..count.." and "..group.."

Example from link:

ggplot(data, aes(carat, fill=color)) +
  geom_histogram(aes(y=c(..count..[..group..==1]/sum(..count..[..group..==1]),
                         ..count..[..group..==2]/sum(..count..[..group..==2]))*100),
                 position='dodge', binwidth=0.5) +
  ylab("Percentage") + xlab("Carat")

Is there any place I can read about these special variables and how they function/interact? My google searches have come up short and I have not been able to find anything through the apropos-command.

Magnus
  • 728
  • 4
  • 17
  • 2
    I guess this https://ggplot2.tidyverse.org/reference/stat.html is a starting point and then in each function, i.e. for [geom_histogram](https://ggplot2.tidyverse.org/reference/geom_histogram.html) it lists the computed variables – kath Nov 07 '19 at 10:50
  • 1
    You can also display the variables including computed variables for a particular invocation of ggplot using `ggplot_build(p)$data` where `p` is the result of your ggplot command. – G. Grothendieck Nov 07 '19 at 11:30

0 Answers0