#load the xlsx package before proceeding EColi <- read.xlsx("Ecoli.xls", 1) #Read the first (and only) worksheet in Ecoli.xls CongWQ <- EColi[substr(EColi$STATION,1,2)=="C-",] CongWQ$lEcoli <- log(CongWQ$Ecoli) CongWQ$lFC <- log(CongWQ$FecalColi) CongWQ$lEntero <- log(CongWQ$Enterococci) #function to embed histograms in matrixplot panel.hist <- function(x, ...) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h <- hist(x, plot = FALSE) breaks <- h$breaks; nB <- length(breaks) y <- h$counts; y <- y/max(y) rect(breaks[-nB], 0, breaks[-1], y, col="pink ", ...) } #matrix scatter plot pairs(CongWQ[,12:14],diag.panel=panel.hist) lCongWQ.lm <- lm(lEcoli ~ lFC + lEntero,data=CongWQ) summary(lCongWQ.lm) par(mfrow=c(2,2)) plot(lCongWQ.lm) confint(lCongWQ.lm, level=0.90) #SENIC data set senic <- read.delim("SENIC.txt",header=T) pairs(senic[,-1],cex=.5) SENIC.lm <- lm(Infection ~ Stay + Facilities + Xray,data=senic)