2021.09.29. Quiz 4
library(gapminder)
library(tidyverse)
 
## -- Attaching packages ---------------------------- tidyverse 1.3.1 --
## √ tibble  3.1.4     √ dplyr   1.0.7
## √ tidyr   1.1.3     √ stringr 1.4.0
## √ readr   2.0.1     √ forcats 0.5.1
## √ purrr   0.3.4
## -- Conflicts ------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
 Quiz 4-1
gapminder %>%
  filter(year=="2007") %>%
  ggplot(mapping = aes(x = lifeExp, fill = continent)) +
  geom_histogram()
 
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

 
 Quiz 4-2
gapminder %>%
  filter(year=="2007") %>%
  ggplot(mapping = aes(x = lifeExp, fill = continent)) +
  geom_histogram() +
  facet_grid(cols = vars(continent))
 
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

 
 Quiz 4-3
gapminder %>%
  filter(year=="2007") %>%
  ggplot(mapping = aes(y = lifeExp, fill = continent)) +
  geom_boxplot()
 

 
 Quiz 4-4
ggplot(gapminder, aes(year, lifeExp, group = country, color = continent)) + geom_line()
 

 
 Quiz 4-5
ggplot(gapminder, aes(year, lifeExp, group = country, color = continent)) + 
  geom_line() + 
  facet_grid(cols = vars(continent))
 

 
 Quiz 4-6
## corrplot 0.90 loaded
data1 <- gapminder %>% filter(year=="2007")
data = data1[,4:6]
cor_matrix=cor(data)
corrplot.mixed(cor_matrix)
 

gapminder %>% 
  filter(year=="2007") %>%
  select(lifeExp, pop, gdpPercap) %>%
  cor() %>%
  corrplot.mixed()
 
