4.9 Data, aesthetics mappings and layers: Exercise 2
- Figure 4.2 visualizes the four different statements.
p1 <- ggplot(mpg, aes(cty, hwy)) + geom_point()
p2 <- ggplot(diamonds, aes(carat, price)) + geom_point()
p3 <- ggplot(economics, aes(date, unemploy)) + geom_line()
p4 <- ggplot(mpg, aes(cty)) + geom_histogram()
grid.arrange(p1, p2, p3, p4, ncol=2)

Figure 4.2: Different geoms