Equivalent coding between qplot and ggplot
In this section, we will have a look at how we can realize a few of the plots we introduced in Chapter 2, Getting Started, with the ggplot()
function we have introduced in this chapter. The idea is that you can use this simple roadmap as guidance on how to use the ggplot()
function to generate several kinds of plots, building on the knowledge of qplot()
that you already have. We will not go into too much detail about the different plots since many basic concepts have already been introduced in the previous chapter and they apply to both functions.
In the following examples, we will use a few of the geom
and stat
functions listed in the summary tables previously presented; just remember that for each of these functions, you can map different aesthetic attributes. You can find a list of such attributes in the summary tables or in the help page of the function.
Histograms and density plots
In order to obtain a histogram, we will use the ggplot()
function...