Introduction

This presentation explores the relationship between a country’s wealth and life expectancy using the Gapminder dataset.

Interactive Plot

library(plotly)
## Warning: package 'plotly' was built under R version 4.5.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.5.3
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(gapminder)
## Warning: package 'gapminder' was built under R version 4.5.3
data_2007 <- gapminder[gapminder$year == 2007, ]

plot_ly(
  data = data_2007,
  x = ~gdpPercap,
  y = ~lifeExp,
  size = ~pop,
  color = ~continent,
  text = ~country,
  type = "scatter",
  mode = "markers",
  hoverinfo = "text",
  sizes = c(10, 60)
) %>%
  layout(
    title = "GDP per Capita vs Life Expectancy (2007)",
    xaxis = list(title = "GDP per Capita", type = "log"),
    yaxis = list(title = "Life Expectancy (Years)")
  )
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.
## Warning: `line.width` does not currently support multiple values.

Conclusion

The interactive graph allows us to compare countries, explore differences between continents, and investigate the relationship between income and life expectancy.

Document created on October 26, 2026.