Proj2

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dslabs)
head(gapminder)
              country year infant_mortality life_expectancy fertility
1             Albania 1960           115.40           62.87      6.19
2             Algeria 1960           148.20           47.50      7.65
3              Angola 1960           208.00           35.98      7.32
4 Antigua and Barbuda 1960               NA           62.97      4.43
5           Argentina 1960            59.87           65.39      3.11
6             Armenia 1960               NA           66.86      4.55
  population          gdp continent          region
1    1636054           NA    Europe Southern Europe
2   11124892  13828152297    Africa Northern Africa
3    5270844           NA    Africa   Middle Africa
4      54681           NA  Americas       Caribbean
5   20619075 108322326649  Americas   South America
6    1867396           NA      Asia    Western Asia
options(scipen=0)

big_four <- c("United States", "Russia", "United Kingdom", "China")
gapminder_filtered <- gapminder %>%
  filter(year %in% c(1989, 2011), country %in% big_four)

ggplot(gapminder_filtered, aes(x = gdp / 1e9, y = life_expectancy, color = country, size = population)) +
  geom_point() +
  labs(title = "Life Expectancy vs. GDP for Big 4 Allies (1989 & 2011)",
       x = "GDP (Billions USD)",
       y = "Life Expectancy (Years)") +
  theme_minimal() +
  scale_color_manual(values = c("blue", "green", "red", "purple", "orange")) +
  theme(legend.position = "bottom") +
  facet_grid(~year)

I used the “gapminder” dataset, which contains information about various countries over time, including variables such as life expectancy, GDP, fertility rate, population, continent, region, and year. Specifically, I filtered the dataset to include data for the “Big 4” (the largest allies of WWI) during the years 1989 and 2011, focusing on life expectancy and GDP. The most limiting aspect of creating this graph was the lack of information on Russia.