R Language Base Plotting Density plot


A very useful and logical follow-up to histograms would be to plot the smoothed density function of a random variable. A basic plot produced by the command

plot(density(rnorm(100)),main="Normal density",xlab="x")

would look like

rnorm density plot example

You can overlay a histogram and a density curve with

hist(x,prob=TRUE,main="Normal density + histogram")

which gives

Overlay rnorm