[R] Histogram

Duncan Murdoch murdoch.duncan at gmail.com
Thu Jul 5 21:48:14 CEST 2012


On 05/07/2012 3:34 PM, Sarah Goslee wrote:
> Hi Jim,
>
> You can't specify both number of bins and bin size. You can specify
> breaks: either the number of bins or the location of breakpoints. A
> histogram with 20 bins of 50 observations each must by definition come
> from a uniform distribution.

Only if the bins are equal in size.  You could set the bins to 
quantiles, for the following ugly plot:

hist(x, breaks=quantile(x, seq(0, 1, by=0.05)))

Duncan Murdoch

>
> What are you trying to accomplish?
>
> Sarah
>
> On Thu, Jul 5, 2012 at 3:29 PM, Jim Silverton <jim.silverton at gmail.com> wrote:
> > I have a column of 1000 datapoints from the normal distribution with mean 2
> > and variance 4. How can I get a histogram of these observations with 20
> > bins with each bin having 50 observations?
> >
> > --
> > Thanks,
> > Jim.
>
>



More information about the R-help mailing list