5.1 Introduction
5.3 Looking at pairs of continuous variables
5.4 Adding models: lines and smooths
5.5 Comparing groups within scatterplots
5.6 Scatterplot matrices for looking at many pairs of variables
Introduction | 76
data(oly12, package="VGAMdata") ggplot(oly12, aes(Height, Weight)) + geom_point() + ggtitle("Athletes at the London Olympics 2012")
Looking at pairs of continuous variables| 78
data(DrinksWages, package="HistData") ggplot(DrinksWages, aes(drinks/n, wage)) + geom_point() + xlab("Proportion of drinkers") + xlim(0,1) + ylim(0,40)
79
bigDW 4) ggplot(bigDW, aes(drinks/n, wage)) + geom_point() + xlab("Proportion of drinkers") + xlim(0,1) + ylim(0,40)
80
data(geyser, package="MASS") ggplot(geyser, aes(duration, waiting)) + geom_point()
81
ggplot(geyser, aes(duration, waiting)) + geom_point() + geom_density2d()
library(hdrcde) par(mar=c(3.1, 4.1, 1.1, 2.1)) with(geyser, hdr.boxplot.2d(duration, waiting, show.points=TRUE, prob=c(0.01,0.05,0.5,0.75)))
82
ggplot(movies, aes(votes, rating)) + geom_point() + ylim(1,10)
Adding models: lines and smooths| 83
data(Cars93, package="MASS") ggplot(Cars93, aes(Weight, MPG.city)) + geom_point() + geom_smooth(colour="green") + ylim(0,50)/pre>
84
data(father.son, package="UsingR") ggplot(father.son, aes(fheight, sheight)) + geom_point() + geom_smooth(method="lm", colour="red") + geom_abline(slope=1, intercept=0)
85
data(father.son, package="UsingR") ggplot(father.son, aes(fheight, sheight)) + geom_point() + geom_smooth(method="lm", colour="red", se=FALSE) + stat_smooth()
87
oly12S
Scatterplot matrices for looking at many pairs of variables| 89
data(crime.us, package="VGAMdata") crime.usR
90
library(car) data(bank, package="gclus") par(mar=c(1.1, 1.1, 1.1, 1.1)) spm(select(bank, Length:Diagonal), pch=c(16, 16), diagonal="histogram", smoother=FALSE, reg.line=FALSE, groups=bank$Status)