Skip to content
Prev 77570 / 398502 Next

Add function to histogram?

Le 21.09.2005 10:00, Peter Wolf a ??crit :
For a frequency polygon, try to work around that piece of code, 
following Peter's notations :

dat <- rnorm(100)
h <- hist(dat,prob=TRUE, border="gray", col="gray90")
diffBreaks <- diff(h$breaks)[1]
xx <- c(h$mids[1]-diffBreaks, h$mids, tail(h$mids,1)+diffBreaks)
yy <- c(0, h$density, 0)
lines(xx, yy, lwd=2)

However, you might prefer (and that's probably wise) the kernel density 
estimator : density() that other people suggested.

Romain