# May have to do this, just once, if you haven't done this or library(alr4) below doesn't run # # install.packages("alr4") # # library(alr4) plot(dheight ~ mheight, data=Heights) ?Heights Heights plot(Heights$mheight, Heights$dheight) with(Heights, plot(mheight, dheight)) plot(round(dheight) ~ round(mheight), Heights) round(Heights) sel <- with(Heights, (57.5 < mheight) & (mheight <= 58.5) | (62.5 < mheight) & (mheight <= 63.5) | (67.5 < mheight) & (mheight <= 68.5)) sel Heights$mheight[1:5] plot(dheight ~ mheight, data=Heights, subset=sel) plot(dheight ~ mheight, data=Heights, subset= !sel) ?Forbes Forbes oldpar <- par(mfrow=c(1, 2)) plot(pres ~ bp, data=Forbes, xlab="Boiling Point (deg. F)", ylab="Pressure (in Hg)") m0 <- lm(pres ~ bp, data=Forbes) m0 abline(m0) m1 = lm(pres ~ bp, data=Forbes) m1 plot(residuals(m0) ~ bp, Forbes, xlab="Boiling Point (deg. F)", ylab="Residuals") abline(a=0, b=0, lty=2) abline(h=0, lty=2) par(oldpar) wblake ?wblake meanLength <- with(wblake, tapply(Length, Age, mean)) (meanLength <- with(wblake, tapply(Length, Age, mean))) plot(Length ~ Age, data=wblake) # fix abline(lm(Length ~ Age, data=wblake)) lines(1:8, meanLength, lty=2) ?plot ?abline ?ftcollinssnow ftcollinssnow ?turkey turkey plot(Gain ~ A, turkey, xlab="Amount (percent of diet)", ylab="Weight gain (g)", pch=S) legend("bottomright", inset=0.02, legend=c("1 Control", "2 New source A", "3 New source B"), cex=0.75, lty=1:3, pch=1:3, lwd=c(1, 1.5, 2)) plot(Gain ~ A, turkey, xlab="Amount (percent of diet)", ylab="Weight gain (g)", pch=S) legend("bottomright", inset=0.02, legend=c("1 Control", "2 New source A", "3 New source B"), cex=0.9, lty=1:3, pch=1:3, lwd=c(1, 1.5, 2)) ?fuel2001 fuel2001 names(fuel2001) summary(fuel2001) fuel2001 <- transform(fuel2001, Dlic=1000 * Drivers/Pop, Fuel=1000 * FuelC/Pop, Income = Income/1000) names(fuel2001) ?transform fuel2001$FuelPerDriver <- fuel2001$FuelC / fuel2001$Drivers names(fuel2001) pairs(~ Tax + Dlic + Income + log(Miles) + Fuel, data=fuel2001) pairs(~ Fuel + Tax + Dlic + Income + log(Miles), data=fuel2001) pairs(fuel2001[, c(7, 9, 3, 6)]) fuel2001[ , c(7, 9, 3, 6)] fuel2001[1:10, ]