Objective

The aim is to analyze and visualize global economic and social indicators such as life expectancy, GDP per capita, and population across various countries and years. The insights will highlight disparities, trends, and patterns in development worldwide.

Load Libraries

library(gapminder)
## Warning: package 'gapminder' was built under R version 4.4.2
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.2
data("gapminder")
gapminder_filtered <- gapminder %>%
  select(country, year, lifeExp, gdpPercap, pop, continent) %>%
  filter(year >= 2000) %>%  # Focus on data from the year 2000 onwards
  mutate(gdp_billion = gdpPercap * pop / 1e9)  # Calculate GDP in billion dollars
summary_table <- gapminder_filtered %>%
  group_by(continent) %>%
  summarise(
    avg_lifeExp = mean(lifeExp, na.rm = TRUE),
    avg_gdpPercap = mean(gdpPercap, na.rm = TRUE),
    total_pop = sum(pop, na.rm = TRUE)
  ) %>%
  arrange(desc(total_pop))

# Display the top rows
head(summary_table)
## # A tibble: 5 × 4
##   continent avg_lifeExp avg_gdpPercap  total_pop
##   <fct>           <dbl>         <dbl>      <dbl>
## 1 Asia             70.0        11324. 7413756030
## 2 Africa           54.1         2844. 1763263608
## 3 Americas         73.0        10145. 1748643946
## 4 Europe           77.2        23383. 1164322398
## 5 Oceania          80.2        28374.   48004776
ggplot(gapminder_filtered, aes(x = gdpPercap, y = lifeExp, color = continent, size = pop)) +
  geom_point(alpha = 0.7) +
  scale_x_log10() +  # Log scale for GDP per capita
  labs(
    title = "Life Expectancy vs GDP per Capita (2000 onwards)",
    x = "GDP per Capita (log scale)",
    y = "Life Expectancy"
  ) +
  theme_minimal()

ggplot(summary_table, aes(x = reorder(continent, total_pop), y = total_pop / 1e9, fill = continent)) +
  geom_bar(stat = "identity") +
  labs(
    title = "Population by Continent",
    x = "Continent",
    y = "Population (Billion)"
  ) +
  theme_minimal()

#Visualizations Scatter Plot: Life Expectancy vs GDP per Capita We will create a scatter plot to visualize the relationship between life expectancy and GDP per capita. The plot will include a log scale for GDP per capita and color the points by continent. #Bar Plot: Population by Continent We will create a bar plot to show the population distribution across different continents. #Key Findings Life Expectancy vs GDP: Countries with higher GDP per capita generally have higher life expectancy, but some outliers exist where life expectancy is not proportional to GDP.

Population Trends: Asia accounts for the largest population, followed by Africa, with significant implications for resource allocation and development.

Regional Disparities: Continents show stark differences in average GDP per capita and life expectancy, highlighting areas needing development focus.

#Conclusion This analysis has provided a deeper understanding of global trends in economic development and social progress. Further investigation is needed to identify specific policies that could address disparities between continents and countries.