In: Math
For this exercise, you will need to use the package `mosaic` to find numerical and graphical summaries.
```{r warning=FALSE, message=FALSE}
# install packages if necessary
if (!require(mosaic)) install.packages(`mosaic`)
if (!require(dplyr)) install.packages(`dplyr`)
if (!require(gapminder)) install.packages(`gapminder`)
# load the package in R
library(mosaic) # load the package mosaic to use its
functions
library(dplyr) # load the package dplyr to use its functions
library(gapminder) # load the package gapminder for question
1
```
1. Using the gapminder data in the lesson, do the following:
i) use `filter` to select all countries with the following
arguments:
a) life expectancy larger than 60 years.
b) United Kingdom and Vietnam and years greater than 1990.
ii) use `arrange` and `slice` to select the countries with the top
15 GDP per capital `gdpPercap`. Use the pipe `%>%` operator to
string multiple functions.
iii) use `mutate` to create a new variable called
`gdpPercap_lifeExp` which is the quotient of `gdpPercap` and
`lifeExp` and display the output.
iv) use `summarise` to find the average or mean value of the
variable `gdpPercap_lifeExp` created in part (iii).
v) use `group_by` to group the countries by `continent`; and
`summarise` to compute the average life expectancy `lifeExp` within
each continent. Use the pipe `%>%` operator to string multiple
functions.
### Code chunk
```{r}
# load the necessary packages
library(mosaic)
library(dplyr)
library(gapminder)
# last R code line
```