A quick alternative
ggmap also provides a quick alternative to ggmap(). Like qplot() in ggplot2, qmplot() is less flexible than a full specification, but often involves significantly less typing. qmplot() replaces both steps -- downloading the map and displaying the map -- and its syntax is a blend between qplot(), get_map(), and ggmap().
Let's take a look at the qmplot() version of the faceted plot from the previous exercise:
qmplot(lon, lat, data = sales,
geom = "point", color = class) +
facet_wrap(~ class)
Notice we didn't specify a map, since qmplot() will grab one on its own. Otherwise the qmplot() call looks a lot like the corresponding qplot() call: use points to display the sales data, mapping lon to the x-axis, lat to the y-axis, and class to color. qmplot() also sets the default dataset and mapping (without the need for base_layer) so you can add facets without any extra work.
This exercise is part of the course
Visualizing Geospatial Data in R
Exercise instructions
Using the example as a guide, use qmplot() to create a plot of the house sales where color is mapped to bedrooms, faceted by month.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot house sales using qmplot()