[R] How to obtain Frequency Tables for Histogram outputs and Frequency Polygons

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jul 12 07:12:11 CEST 2005

On 7/12/05, Tan Hui Hui Jenny <medp9193 at nus.edu.sg> wrote:
> Couple of questions:
> 1. How can I obtain the frequency tables for a histogram chart?
> 2. Is there a short cut to obtain the frequency polygons directly without having to generate the frequency table and doing a line plot?

res <- hist(x)  # res contains various data about histogram

# create red polygons using rect
plot(range(res$breaks), range(res$counts), type="n")
rect(res$breaks[-length(res$breaks)],0,res$breaks[-1],res$counts, col="red")

More information about the R-help mailing list