Note:This horizontal bar chart ranks countries by their HDI values in 2017. HDI measures overall development by combining indicators of life expectancy, education, and income. High HDI countries are mostly located in Europe, North America, and Oceania, with darker or more vibrant color regions. Lower HDI countries (those toward the top of the chart after flipping) are concentrated in Sub-Saharan Africa and parts of Asia, showing wide disparities across regions. This chart is useful for quickly spotting countries with the highest and lowest levels of human development in 2017.
Notes:Each dot represents a country, ranked by HDI (lower number = higher HDI). Countries like Norway, Switzerland, and Ireland appear at the bottom (best ranks). The distribution shows that top-ranked countries cluster more tightly together than lower-ranked ones, meaning smaller HDI differences among the top countries. Regional patterns are visible: Europe and OECD countries dominate the lower end of the axis, while Africa and some South Asian countries occupy higher rank numbers.
Notes:This bar chart shows life expectancy at birth across countries. Countries with high HDI tend to have higher life expectancy, generally above 75 years. Conversely, countries with lower HDI often have life expectancy below 65 years. The regional fill shows patterns—African countries are predominantly at the lower end, reflecting challenges in healthcare and living conditions.
Notes:This zooms in on the best performers globally. All top 10 countries are high-income, industrialized nations, many in Western Europe, North America, and Oceania.They combine high income, excellent healthcare, and strong educational systems. The chart reinforces the correlation between wealth and HDI, but also the role of effective governance and social policies.
Notes:A scatter plot that reveals a strong positive correlation between HDI and life expectancy. Regions like Europe and Oceania cluster in the top right—high HDI and high life expectancy.African and some Asian countries are in the lower-left quadrant. Outliers, if any, could suggest countries with relatively high life expectancy but lower HDI, perhaps due to weak education or income metrics.
Notes:Density plots show how HDI values are distributed within each region. Europe and Central Asia have a tight distribution at the high end of HDI.Sub-Saharan Africa has a broad, left-skewed distribution indicating overall low HDI with significant variability.This chart illustrates within-region inequality and how some regions are universally better or worse off.
Notes:Bar chart of country counts per region. Sub-Saharan Africa and Europe & Central Asia have the largest number of countries represented.The number of countries affects how much weight a region carries in global development discussions and statistics.This context is useful when comparing regional HDI averages, to avoid misleading conclusions due to unequal region sizes.
Notes:A distribution of HDI scores globally. The chart likely shows a bimodal or skewed shape, reflecting two main clusters—one group with medium-to-high HDI and another with low HDI. Most countries cluster between 0.5 and 0.85 HDI, with fewer countries at the extremes. This reveals that while many countries are progressing, global development is uneven, with a long tail of underdeveloped countries.
---
title: "Study of 40 countries by HDI (Human Development Indicator) "
author: "Bamba"
output:
flexdashboard::flex_dashboard:
storyboard: true
social: menu
source: embed
---
```{r setup, include=FALSE}
# Load required libraries
library(flexdashboard)
library(tidyverse)
library(readxl)
library(DBI)
library(duckdb)
library(janitor)
library(ggplot2)
library(plotly)
library(knitr)
# Set chunk options
knitr::opts_chunk$set(echo = TRUE)
# Connect to DuckDB
con <- dbConnect(duckdb::duckdb(), dbdir = "C:/Users/Faculty-Staff/Downloads/world_data.duckdb", read_only = FALSE)
# Load datasets
HDI <- read_csv("C:/Users/Faculty-Staff/Downloads/Worldhdi0521.csv")
world_bank <- read_excel("C:/Users/Faculty-Staff/Downloads/WorldBank.xlsx")
# Write datasets to DuckDB
dbWriteTable(con, "HDI", HDI, overwrite = TRUE)
dbWriteTable(con, "world_bank", world_bank, overwrite = TRUE)
# Join datasets on Country and Countrycode
query <- "
SELECT *
FROM HDI
LEFT JOIN world_bank
USING (Country, Countrycode)
"
combined <- dbGetQuery(con, query)
# Clean column names
combined <- janitor::clean_names(combined)
# OPTIONAL: disconnect after all charts (NOT here in setup)
# dbDisconnect(con, shutdown = TRUE)
knitr::opts_chunk$set(echo = TRUE)
```
### CHART 1: HDI per Country in 2017
```{r echo=FALSE}
ggplotly(
ggplot(combined, aes(x = reorder(country, hdi_2017), y = hdi_2017, fill = region)) +
geom_col(alpha = 0.8) +
coord_flip() +
theme_minimal() +
labs(title = "HDI per Country in 2017", y = "HDI", x = "Country")
)
```
***
Note:This horizontal bar chart ranks countries by their HDI values in 2017.
HDI measures overall development by combining indicators of life expectancy, education, and income.
High HDI countries are mostly located in Europe, North America, and Oceania, with darker or more vibrant color regions.
Lower HDI countries (those toward the top of the chart after flipping) are concentrated in Sub-Saharan Africa and parts of Asia, showing wide disparities across regions.
This chart is useful for quickly spotting countries with the highest and lowest levels of human development in 2017.
### Chart 2: HDI Rank of Countries in 2017
```{r echo=FALSE}
ggplotly(
ggplot(combined, aes(x = reorder(country, hdi_rank_2017), y = hdi_rank_2017, color = region)) +
geom_point(size = 3) +
coord_flip() +
theme_minimal() +
labs(title = "HDI Rank of Countries (2017)", x = "Country", y = "HDI Rank")
)
```
***
Notes:Each dot represents a country, ranked by HDI (lower number = higher HDI).
Countries like Norway, Switzerland, and Ireland appear at the bottom (best ranks).
The distribution shows that top-ranked countries cluster more tightly together than lower-ranked ones, meaning smaller HDI differences among the top countries.
Regional patterns are visible: Europe and OECD countries dominate the lower end of the axis, while Africa and some South Asian countries occupy higher rank numbers.
### CHART 3: Life Expectancy at Birth (2017) by Country
```{r echo=FALSE}
ggplotly(
ggplot(combined, aes(x = reorder(countrycode, lifeexpectancyatbirth_2017), y = lifeexpectancyatbirth_2017, fill = region)) +
geom_col() +
theme_light() +
labs(title = "Life Expectancy at Birth by Country (2017)", x = "Country", y = "Life Expectancy")
)
```
***
Notes:This bar chart shows life expectancy at birth across countries.
Countries with high HDI tend to have higher life expectancy, generally above 75 years.
Conversely, countries with lower HDI often have life expectancy below 65 years.
The regional fill shows patterns—African countries are predominantly at the lower end, reflecting challenges in healthcare and living conditions.
### Chart 4: Top 10 Countries by HDI (2017)
```{r echo=FALSE}
ggplotly(
combined %>%
filter(!is.na(hdi_2017)) %>%
slice_max(order_by = hdi_2017, n = 10) %>%
ggplot(aes(x = reorder(country, hdi_2017), y = hdi_2017, fill = region)) +
geom_col() +
coord_flip() +
theme_minimal() +
labs(title = "Top 10 Countries by HDI (2017)", x = "Country", y = "HDI")
)
```
***
Notes:This zooms in on the best performers globally.
All top 10 countries are high-income, industrialized nations, many in Western Europe, North America, and Oceania.They combine high income, excellent healthcare, and strong educational systems.
The chart reinforces the correlation between wealth and HDI, but also the role of effective governance and social policies.
### Chart 5: HDI vs Life Expectancy (2017)
```{r echo=FALSE}
ggplotly(
ggplot(combined, aes(x = hdi_2017, y = lifeexpectancyatbirth_2017, color = region)) +
geom_point(size = 3, alpha = 0.7) +
theme_minimal() +
labs(title = "HDI vs Life Expectancy (2017)", x = "HDI (2017)", y = "Life Expectancy at Birth (2017)")
)
```
***
Notes:A scatter plot that reveals a strong positive correlation between HDI and life expectancy.
Regions like Europe and Oceania cluster in the top right—high HDI and high life expectancy.African and some Asian countries are in the lower-left quadrant.
Outliers, if any, could suggest countries with relatively high life expectancy but lower HDI, perhaps due to weak education or income metrics.
### Chart 6: HDI Distribution by Region (2017)
```{r echo=FALSE}
ggplotly(
ggplot(combined, aes(x = hdi_2017, fill = region)) +
geom_density(alpha = 0.5) +
theme_minimal() +
labs(title = "HDI Distribution by Region (2017)", x = "HDI (2017)", y = "Density")
)
```
***
Notes:Density plots show how HDI values are distributed within each region.
Europe and Central Asia have a tight distribution at the high end of HDI.Sub-Saharan Africa has a broad, left-skewed distribution indicating overall low HDI with significant variability.This chart illustrates within-region inequality and how some regions are universally better or worse off.
### Chart 7: Number of Countries per Region
```{r echo=FALSE}
ggplotly(
combined %>%
filter(!is.na(region)) %>%
ggplot(aes(x = region, fill = region)) +
geom_bar() +
theme_minimal() +
labs(title = "Number of Countries per Region", x = "Region", y = "Count") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
)
```
***
Notes:Bar chart of country counts per region.
Sub-Saharan Africa and Europe & Central Asia have the largest number of countries represented.The number of countries affects how much weight a region carries in global development discussions and statistics.This context is useful when comparing regional HDI averages, to avoid misleading conclusions due to unequal region sizes.
### Chart 8: Global distribution of HDI in 2017
```{r echo=FALSE}
ggplotly(
ggplot(combined, aes(x = hdi_2017)) +
geom_histogram(bins = 30, fill = "darkgreen", color = "white") +
theme_classic() +
labs(title = "Distribution of hdi_2017", x = "hdi_2017", y = "Frequency")
)
```
***
Notes:A distribution of HDI scores globally.
The chart likely shows a bimodal or skewed shape, reflecting two main clusters—one group with medium-to-high HDI and another with low HDI.
Most countries cluster between 0.5 and 0.85 HDI, with fewer countries at the extremes.
This reveals that while many countries are progressing, global development is uneven, with a long tail of underdeveloped countries.
### Chart 9: Share of Countries by Region (Pie Chart)
```{r echo=FALSE}
region_counts <- combined %>%
filter(!is.na(region)) %>%
count(region, name = "country_count") %>%
mutate(label = region)
plot_ly(
data = region_counts,
labels = ~label,
values = ~country_count,
type = "pie",
textinfo = "label+percent",
insidetextorientation = "radial"
) %>%
layout(title = "Proportion of Countries by Region")
```
***
Notes:this chart displays the proportion of countries from each region.
Regions like Sub-Saharan Africa and Europe & Central Asia contribute a large share of countries.This pie chart helps contextualize the other charts: for instance, Sub-Saharan Africa’s strong presence in lower HDI ranges is due in part to the number of countries it includes.The chart also helps explain regional representation in the dataset, which is essential for equitable analysis.