density(x, n=50, window="g", na.rm=F, width=<<see below>>, from=<<see below>>, to=<<see below>>, cut=<<see below>>)
These are kernel estimates. For each x value in the output, the window is centered on that x and the heights of the window at each datapoint are summed. This sum, after a normalization, is the corresponding y value in the output. Results are currently computed to single-precision accuracy only.
Wegman, E. J. (1972). Nonparametric probability density estimation. Technometrics, 14, 533-546.
plot(density(x), type="b")den.co2 <- density(co2, width=4) hist(co2) den.co2$y <- den.co2$y*length(co2)*2 # multiply density by length of series and width of histogram bar lines(den.co2)