[R] Insert values to histogram
Jim Lemon
jim at bitwrit.com.au
Fri May 6 10:35:58 CEST 2011
On 05/05/2011 09:50 PM, matibie wrote:
> I'm trying to add the exact value on top of each column of an Histogram, i
> have been trying with the text function but it doesn't work.
> The problem is that the program it self decides the exact value to give to
> each column, and ther is not like in a bar-plot that I know exactly which
> values are been plotting.
Hi Matias,
You are probably using the "hist" function in the graphics package. If
so, that function returns a list containing components named "counts"
(for frequency histograms) and "density" (for density histograms). So if
you collect that list:
histinfo<-hist(...)
histinfo$counts
you will see the heights of the bars. As Greg has noted, many people do
not agree with adding the counts to the plot, but if you want to do it,
there are your numbers.
Jim
More information about the R-help
mailing list