[R] Getting the values out of histogram (lattice)

Monica Pisica pisicandru at hotmail.com
Wed Aug 31 15:50:16 CEST 2011




Hi,

 

I have a relatively big dataset and I want to construct
some histograms using the histogram function in lattice. One thing I am
interested in is to look at differences between density and percent. I know I can
use the hist function but it seems that this function gives sometimes some
wrong answers and the density is actually a percent since it is calculated as counts in the bin divided by the total no. of points. Let me explain.

 

If I let the hist function to decide the breaks, or I use
a small number, or one of the pre-determined methods to select breaks then
everything seems to be in order. But if I decide to use – for example – 100 as
a breaks (I have over 90000 data points so the number of breaks is not
necessarily too large I would think) the density for the first bin is over 1,
although for all the other breaks the density is actually a percent since it is
the count for that bin divided by the total no. of points I have. So …. Here it
is something wrong or most probably I am doing something wrong. 

 

If I use the function histogram from lattice it is
obvious that there is a difference between the percent param and the density
param. I looked at the function code and I didn't understand it – to be honest.
It seems it calls inside the hist function, or a slightly modify variant of
hist. Reading about the object trellis I saw I can access different info about
the graph it generates but nothing about the actual data that goes into
defining the histogram. How can I access the data from it? 

 

I am not sure if my problem is platform specific – it should
not be – but I have Rx64 2.13.1 on windows machine, in case it counts.

 

I appreciate your help, thanks,

 

Monica

 		 	   		  


More information about the R-help mailing list