Chapter 22 Assignments

22.1 Assignments

22.1.1 Assignment 1

In Chapter 10, we used ggplot(mpg, aes(x=cty, colour=drv, fill=drv)) + geom_histogram(binwidth=1) to compare distributions. As we’ve seen for bar charts in 13, default settings can be informative. In this case, it might be good to realise that the default settings within geom_histogram, includes position=stack. Alternatives for ‘position’ are “identity” and “dodge”. Try them both and explain what’s going on. Also compare them to ggplot(mpg, aes(x=cty, colour=drv, fill=drv)) + geom_freqpoly(binwidth=1)

22.1.2 Assignment 2

We’re interested in whether car-models from 2007 are more fuel efficient than those from 1999. Create a boxplot of the variable “cty” (fuel efficiency within the city) on the y-axis and year on the x-axis. Add the raw data by adding jitter. Make the jitter points blue and seethrough!

22.1.3 Assignment 3

Show the association between “displ” and “drv” for the different years using facets.