demo/hist_geyser.R

# a simplified version would be:
# hist(geyser$waiting, freq = FALSE, main = "")
# lines(density(geyser$waiting))
par(mar = c(1.8, 3, 0.5, 0.1), mgp = c(2, 0.5, 0))
data(geyser, package = "MASS")
hst = hist(geyser$waiting, probability = TRUE, main = "", xlab = "waiting")
d = density(geyser$waiting)
polygon(c(min(d$x), d$x, max(d$x)), c(0, d$y, 0), col = "lightgray", border = NA)
lines(d)
ht = NULL
brk = seq(40, 110, 5)
for (i in brk) ht = c(ht, d$y[which.min(abs(d$x - i))])
segments(brk, 0, brk, ht, lty = 3)

Try the MSG package in your browser

Any scripts or data that you put into this service are public.

MSG documentation built on July 22, 2021, 1:06 a.m.