[R] multhist,labels and percentages
Federico Calboli
f.calboli at imperial.ac.uk
Fri May 14 17:51:22 CEST 2010
On 14 May 2010, at 16:09, Thomas Stewart wrote:
> Please be more specific with your question. Perhaps a simple subset of the data you are trying to plot? Here is some non-specific advice:
>
> Plotting histograms as percentages instead of frequency counts is already an option of the hist function. For example,
>
> pop1<-rnorm(100)
> hist(pop1,freq=F)
What you get is a desity, not a percentage, so you could have two bars with a value greater 0.5 on the y-axis. The fact that the area sums up to 1 does not mean that the sum of the heights adds up to 1 --the thing that my ignoramus want to see to understand. On the other hand, freq =T gives the counts, and the sum of the counts is the population total -- therefore (bar counts)/(pop total) *100 is the precentage. If I could slap that on the label of the y-axis I'd be sorted.
>
> If you are plotting two histograms side-by-side (on the percentage scale), the y-axis of both plots can be set with the ylim option. For example,
>
> par(mfrow=c(1,2))
> pop1<-rnorm(100)
> hist(pop1,freq=F,ylim=c(0,1))
> pop2<-rgamma(100,1,1)
> hist(pop2,freq=F,ylim=c(0,1))
I'm using multhist(). The above would not work for me.
F
>
> If your question were clearer, I might be able to help in more specific ways.
>
> -tgs
>
> On Fri, May 14, 2010 at 10:19 AM, Federico Calboli <f.calboli at imperial.ac.uk> wrote:
> Hi All,
>
> I am in the annoying position of having to present some data to someone who seems to be somewhat less than numerate. I need to label the y-axes of a multhist with the y-axis labeled not as counts but as percentage of a population. Plotting the standard histogram is in a way fine, all I need is to:
>
> -- have a left-handside y-axis labels for pop 1 and a right-handside y-axis labels for pop2
> -- replace the counts in each axis with population percentages (easy to calculate, but how to stick them there?)
>
> Any suggestion would be gratefully received.
>
> F
>
>
> --
> Federico C. F. Calboli
> Department of Epidemiology and Biostatistics
> Imperial College, St. Mary's Campus
> Norfolk Place, London W2 1PG
>
> Tel +44 (0)20 75941602 Fax +44 (0)20 75943193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.com
>
> ______________________________________________
> 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.
>
--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG
Tel +44 (0)20 75941602 Fax +44 (0)20 75943193
f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com
More information about the R-help
mailing list