# # 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. # #----- DF = read.csv("../../Data/swedish_hospitals.csv") #postscript("../../WriteUp/Graphics/Chapter1/ex_16_hist_plot.eps", onefile=FALSE, horizontal=FALSE) plot( density(DF$Bill), main="All Hospitals" ) #dev.off() bill_range = range( DF$Bill ) uhospitals = unique( DF$Hospital ) #postscript("../../WriteUp/Graphics/Chapter1/ex_16_kdes_by_hospital.eps", onefile=FALSE, horizontal=FALSE) par(mfrow=c(1,length(uhospitals))) for( hi in uhospitals ){ mask = DF$Hospital == hi plot( density( DF[mask,]$Bill ), xlim=bill_range, main=sprintf("H# %d", hi), xlab="", ylab="" ) } par(mfrow=c(1,1)) #dev.off()