Histograms

Simple Histogram

A simple histogram if obtained with the R-command "hist" in the "base" package.

>crickets<-read.table(file="ramanujan.math.trinity.edu/ekwessi/misc/crickets.txt",header=T)
>hist(crickets$Temperature, col="yellow", main="Histogram of Temperature")




Click to view


Histogram with density

It is possible to overlay a "normal" ( or any other) density over a histogram

>x=crickets$Temperature
>h=hist(x,xlab="Temperature",col="yellow",main="Histogram of Temperature")
>xx=seq(min(x),max(x),0.01)>yy=dnorm(xx,mean=mean(x),sd=sd(x))
>yy=yy*diff(h$mids[1:2])*length(x)
>lines(xx,yy,col="blue")



Click to view