The goal of this practical is to familiarize yourself with `ggplot2`.
The objectives of this session will be to:
- Create basic plot with `ggplot2`
- Understand the `tibble` type
- Learn the different aesthetics in R plots
- Compose graphics
<div id='pencadre'>
**Write the commands in the grey box in the terminal.**
**The expected results will always be printed in a white box here.**
**You can `copy-paste` but I advise you to practice writing directly in the terminal. To validate the line at the end of your command: press `Return`.**
</div>
## Tidyverse
The tidyverse is a collection of R packages designed for data science.
All packages share an underlying design philosophy, grammar, and data structures.
<center>
{width=500px}
</center>
\
```R
install.packages("tidyverse")
```
```R
library("tidyverse")
```
### Toy data set `mpg`
This dataset contains a subset of the fuel economy data that the EPA makes available on http://fueleconomy.gov . It contains only models which had a new release every year between 1999 and 2008.
```{r mpg_inspect, include=TRUE}
?mpg
mpg
```
```{r mpg_inspect2, include=TRUE}
dim(mpg)
```
```R
View(mpg)
```
### New script

\
### Updated version of the data
`mpg` is loaded with tidyverse, we want to be able to read our own data from
geom_point(mapping = aes(x = displ, y = hwy, color = class))
```
### Aesthetic mappings : `color`
`ggplot2` will automatically assign a unique level of the aesthetic (here a unique color) to each unique value of the variable, a process known as scaling. `ggplot2` will also add a legend that explains which levels correspond to which values.