# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- library(DAAG) library(lattice) par(mfrow=c(1,2)) hist( possum$earconch, main="" ) boxplot( earconch ~ sex, data=possum, horizontal=TRUE ) par(mfrow=c(1,1)) par(mfrow=c(1,2)) hist( possum$earconch[possum$sex=="f"], border="red", main="" ) hist( possum$earconch[possum$sex=="m"], border="blue", main="" ) par(mfrow=c(1,1)) histogram( ~ earconch | sex, data=possum ) fden = density( possum$earconch[possum$sex=="f"] ) mden = density( possum$earconch[possum$sex=="m"] ) xlim = range( c(fden$x,mden$x) ) ylim = range( c(fden$y,mden$y) ) plot( fden, col="red", xlim=xlim, ylim=ylim, main="" ) lines( mden, col="blue", lty=2 ) print(densityplot(~earconch, data=possum, groups=sex), main="") fhist = hist( possum$earconch[possum$sex=="f"], plot=F, breaks=seq(from=40, to=58, by=2) ) mhist = hist( possum$earconch[possum$sex=="m"], plot=F, breaks=seq(from=40, to=58, by=2) ) ylim = range( fhist$density, mhist$density ) plot( fhist, freq=F, xlim=c(40,58), ylim=ylim, border="red", main="" ) lines( mhist, freq=F, border="blue", lty=2 ) print( histogram( ~earconch | sex, data=possum ), main="" )