-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path2-12_ggplot2_intro.qmd
27 lines (19 loc) · 1.13 KB
/
2-12_ggplot2_intro.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# ggplot2
The basic plotting functions of R are nice to quickly visualize data, however, the strength of R is that it has many packages with extra functionality created by others that you can use. ggplot2 is one of those packages, created by Hadley Wickham. ggplot2 allows you to build more sophisticated plots in R using a "Grammar of Graphics" (therefore **GG**plot).
If ggplot2 is not yet available for you we need to install and load the ggplot2 library like so.
```{r, eval=FALSE}
install.packages("ggplot2")
library(ggplot2)
```
```{r, echo=FALSE}
library(ggplot2)
```
ggplot2 is a very extensive package, so it is impossible to show all the possibilities during this course. If you would like to experiment further, the ggplot manual at <http://ggplot2.tidyverse.org/reference/index.html> is the place to go. A large variety of functionalities are listed there, including example plots.
## Grammar of graphics
The grammar of graphics consists of a number of "layers", which generate a ggplot when correctly put together. These five basic layers will be discussed here:
- Data
- Aesthetics
- Geometries
- Facets
- Scales
- Themes