Chapter 1 Homework 4

1.1 4-1

gapminder %>% filter(year==“2007”) %>%
dplyr::select(-year) %>%
ggplot(mapping = aes(x = lifeExp, fill = continent)) + stat_bin(aes(color=continent))

1.2 4-2

gapminder %>% filter(year==“2007”) %>%
dplyr::select(-year) %>%
ggplot(mapping = aes(x = lifeExp, fill = continent)) + stat_bin(aes(color=continent)) + facet_wrap(. ~ continent, ncol=3)

1.3 4-3

gapminder %>% filter(year==“2007”) %>%
dplyr::select(-year) %>%
ggplot(mapping = aes(y = lifeExp, fill=continent)) + geom_boxplot()

1.4 4-4

gapminder %>% ggplot(mapping = aes(x = year, y = lifeExp, group = country)) + geom_line(aes(color=continent)) #facet_wrap(. ~ continent, ncol=3)

1.5 4-5

gapminder %>% ggplot(mapping = aes(x = year, y = lifeExp, group = country)) + geom_line(aes(color=continent)) + facet_wrap(. ~ continent, ncol=3)