In the next few pages, you will see how to apply the principles of the The Grammar of Graphics with the ggplot2
package. With this package, you are able to change a lot of details in your graphics and create your own individual style. We will give you examples of some of its main settings.
You can find the
ggplot2
package on CRAN, which makes it very easy to install it:
install.packages("ggplot2")
You are then able to simply load it with the following:
library(ggplot2)
Or, you can just check the box in front of the package name in the packages pane of RStudio:
The ggplot2
package provides two functions to create graphic objects:
qplot() ggplot()
qplot
stands just for quick plot, and ggplot
is an abbreviation of grammar of graphics plot, which shows its strong connection to the framework mentioned earlier.
qplot
aims to be very similar to the basic plot function, and to be very simple to use. But it does not follow the full capacity...