[R] ggplot2: histogram with proportions (or %)

stephen sefick ssefick at gmail.com
Thu Oct 30 15:54:01 CET 2008

this is probably suboptimal - but do it outside of qplot() add it to a
data frame and then qplot() with Hadley's advice.

On Thu, Oct 30, 2008 at 10:19 AM, hadley wickham <h.wickham at gmail.com> wrote:
> On Thu, Oct 30, 2008 at 3:49 AM, ONKELINX, Thierry
> <Thierry.ONKELINX at inbo.be> wrote:
>> Dear Bernd,
>> AFAIK you can only get counts, densitys, counts scale to a maximum of 1
>> and likewise densitys. But you can alter the labels on the scales
>> manually.
> Well, a proportion is just the count divided by the total count, so
> you should be able to do:
> qplot(carat, ..count.. / sum(..count..), data=diamonds, geom="histogram")
> but unfortunately a bug seems to have crept into the latest version
> and this doesn't work.
> Hadley
> --
> http://had.co.nz/
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis

More information about the R-help mailing list