March 2018
Beginner to intermediate
570 pages
13h 42m
English
The canonical way of displaying relationships between two continuous variables is via scatterplots. The scatterplot for the women's heights and weights that we saw earlier in this chapter was produced with the following R code snippet:
qplot(height, weight, data=women, geom="point")
Whether you put height and weight first depends on which variable you want tied to the x axis.
What about that fancy regression line?!, you ask frantically. ggplot2 gracefully provides this feature with just a few extra characters. The scatterplot of the relationship between the weight of a car and its miles per gallon was produced as follows:
qplot(wt, mpg, data=mtcars, geom=c("point", "smooth"),
method="lm", se=FALSE)
Here, we are ...