Africa 1952: scatter plot of GDP per capita versus life expectancy


Commentary about the relation between GDP per capita and life expectancy for African countries in 1952.

Africa 1972: scatter plot of GDP per capita versus life expectancy


Commentary about the relation between GDP per capita and life expectancy for African countries in 1972.

Africa 1992: scatter plot of GDP per capita versus life expectancy


Commentary about the relation between GDP per capita and life expectancy for African countries in 1992.

Africa 2007: scatter plot of GDP per capita versus life expectancy


Commentary about the relation between GDP per capita and life expectancy for African countries in 2007.

---
title: "Gapminder"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    social: menu
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(plotly)
library(gapminder)
library(dplyr)
```


```{r}
dataset = filter(gapminder, continent == "Africa")
years = c(1952, 1972, 1992, 2007)
```


### Africa `r years[1]`: scatter plot of GDP per capita versus life expectancy

```{r}

ds = filter(dataset, year == years[1])

p = ds %>%
  ggplot(aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.5, show.legend = FALSE) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 10)) +
  scale_x_log10() +
  theme_minimal()

ggplotly(p)

```

***

Commentary about the relation between GDP per capita and life expectancy for African countries in `r years[1]`.

### Africa `r years[2]`: scatter plot of GDP per capita versus life expectancy

```{r}

ds = filter(dataset, year == years[2])

p = ds %>%
  ggplot(aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.5, show.legend = FALSE) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 10)) +
  scale_x_log10() +
  theme_minimal()

ggplotly(p)

```

***

Commentary about the relation between GDP per capita and life expectancy for African countries in `r years[2]`.

### Africa `r years[3]`: scatter plot of GDP per capita versus life expectancy

```{r}

ds = filter(dataset, year == years[3])

p = ds %>%
  ggplot(aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.5, show.legend = FALSE) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 10)) +
  scale_x_log10() +
  theme_minimal()

ggplotly(p)

```

***

Commentary about the relation between GDP per capita and life expectancy for African countries in `r years[3]`.

### Africa `r years[4]`: scatter plot of GDP per capita versus life expectancy

```{r}

ds = filter(dataset, year == years[4])

p = ds %>%
  ggplot(aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.5, show.legend = FALSE) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 10)) +
  scale_x_log10() +
  theme_minimal()

ggplotly(p)

```

***

Commentary about the relation between GDP per capita and life expectancy for African countries in `r years[4]`.