[R] confused about histograms

Paul Murrell p.murrell at auckland.ac.nz
Thu Jul 17 23:41:44 CEST 2003


Sounds like a barplot may provide a more appropriate visualisation; see 


Jay Pfaffman wrote:
> I've got a data set with integer codes from 0--3.  I'd like a
> histogram with a single bar for 0, 1, 2 and 3.  I'd like each of the 4
> bars centered over a label.
>     hist(mydata,  breaks=4, main="Simulation") 
> gives me three bars.  The best I've been able to do is do something
> like 
>    print(hist((wexp),  breaks=25, main="Simulation"))
> This gives me something close to what I want, but seems like a silly
> way to do it.  I'm about to give up and have someone do it in Excel
> (which peeves me to no end).
> To further complicate matters, one data set has no items in the zero
> cell.  I'd like that graph to look like the others (using my stupid
> hack above it has bars that are a different width).
> Thanks.

Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz

More information about the R-help mailing list