A comprehensive R-based project that analyzes the Gapminder dataset (1952–2007) to explore global trends in life expectancy, GDP per capita, and population. The analysis produces a suite of 12 visualizations, fits a regression model, and renders an HTML report.
This repository contains everything needed to:
gapminder
R package.Gapminder_report.html
).Ideal for students, educators, data scientists, and anyone interested in global development metrics.
Each plot is saved to gap-<index>.png
and displayed in the R session.
ggplot2
dplyr
gapminder
scales
viridis
tidyr
forcats
zoo
rmarkdown
(for report rendering)The main script auto-installs any missing packages.
Clone this repository:
git clone https://github.com/yourusername/gapminder-analysis.git
cd gapminder-analysis
.env.example
to .env
to customize environment variables.bash scripts/run_gapminder.sh
All 12 charts will print and save as gap-1.png
… gap-12.png
.
bash scripts/render_report.sh
This produces Gapminder_report.html
.
make report
Equivalent to running analysis and report steps.
.
├── Gapminder_Analysis.R # Main R script
├── Gapminder_Analysis.Rmd # RMarkdown report
├── Gapminder_report.html # Generated HTML report
├── gap-*.png # Saved plot images
├── scripts/
│ ├── run_gapminder.sh # Runs the analysis script
│ └── render_report.sh # Renders the RMarkdown
├── Makefile # Make targets for automation
├── Dockerfile # Container definition
├── docker-compose.yml # Compose for containerized run
├── .env.example # Sample environment config
└── README.md # This file
scripts/run_gapminder.sh
Runs Gapminder_Analysis.R
to produce and save all plots.
scripts/render_report.sh
Renders Gapminder_Analysis.Rmd
to Gapminder_report.html
.
Makefile
make analysis
— run shell script to generate plotsmake report
— run analysis + render reportmake clean
— delete images & reportBuild and run in a container:
docker-compose up --build
This will:
All files are shared via a bind mount.
Gapminder_Analysis.R
or .Rmd
.Gapminder dataset via R package:
install.packages("gapminder")
R Packages: see CRAN for ggplot2
, dplyr
, etc.
This project is licensed under the MIT License. See LICENSE for details.