doing facets in ggplot I would often like the percentage to be used instead of counts.
e.g.
test1 <- sample(letters[1:2], 100, replace=T) test2 &
Here is a within ggplot method, using ..count.. and ..PANEL..:
ggplot
..count..
..PANEL..
ggplot(test, aes(test2)) + geom_bar(aes(y = (..count..)/tapply(..count..,..PANEL..,sum)[..PANEL..])) + facet_grid(~test1)
As this is computed on the fly, it should be robust to changes to plot parameters.