Load libraries

library(gapminder) library(dplyr)

Load the data

data(“gapminder”)

Select relevant columns and filter data for analysis

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

# Summarize data by continent 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)

library(ggplot2)

Scatter plot with ggplot2

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()

# Bar plot 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()

Findings and Interpretation