[R] Understanding R Hist() Results...

Philipp Pagel p.pagel at wzw.tum.de
Thu Jun 4 09:50:40 CEST 2009


On Wed, Jun 03, 2009 at 09:00:11PM -0700, Jason Rupert wrote:
> 
> http://n2.nabble.com/What-is-going-on-with-Histogram-Plots-td3022645.html
> 
> For my example I count 7 unique years, however, on the histogram
> there only 6.  It looks like the bin to the left of the tic mark on
> the x-axis represents the number of entries for that year, i.e.
> Frequency.   
> 
> I guess it looks like the bin for 1990 is missing.  Is there a
> better way or a different histogram R command to use in order to see
> all the age bins and them for them to be aligned directly over the
> year tic mark on the x-axis?  

hist() is most useful for non-integer data. Each bin represents an
interval and for discrete data several values can of course end up in
the same bin - just as for floating point numbers. What you want is a
graphical representation of counts for discret values (dates) - try

plot(table(HouseYear_array))

  or

barplot(table(HouseYear_array))

instead.

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/




More information about the R-help mailing list