2025-03-28

R Code

library(dplyr)
library(ggplot2)
library(plotly)
gni_data <- read.csv("GNI_data_renamed.csv", header = TRUE)

Describing the data

The dataset contains information on Gross National Income (GNI) per capita for countries around the world, covering the years 1990 through 2021. The data was compiled by the United Nations Development Programme (UNDP) as part of their Human Development Reports. The data is used to analyze economic growth over time, global and regional income disparities, and it links between income, development status, and geography.

Link-> https://www.kaggle.com/datasets/iamsouravbanerjee/gross-national-income-per-capita/data

ggplot 1 – output

R Code for ggplot: GNI Per Capita by Continent

gni_data %>%
  filter(!is.na(GNI_2021), !is.na(Continent)) %>%
  ggplot(aes(x = Continent, y = GNI_2021, fill = Continent)) +
  geom_boxplot() +
  labs(title = "Distribution of GNI Per Capita by Continent (2021)",
       x = "Continent", y = "GNI Per Capita (USD)") +
  theme_minimal()

ggplot 2 - plot

ggplot 2 - code

gni_data %>%
  group_by(Human.Development.Groups, UNDP.Developing.Regions) %>%
  summarise(avg_gni_2021 = mean(GNI_2021, na.rm = TRUE)) %>%
  ggplot(aes(x = Human.Development.Groups, y = avg_gni_2021, fill = UNDP.Developing.Regions)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(title = "Average GNI by Human Development Group and UNDP Region (2021)",
       x = "Human Development Group",
       y = "Average GNI (USD)",
       fill = "UNDP Region") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

plotly 1 (3D Version) - plot

plotly 1 (3D Version) - code

plot_ly(
  data = gni_data,
  x = ~GNI_1990,
  y = ~GNI_2000,
  z = ~GNI_2021,
  type = "scatter3d",
  mode = "markers",
  color = ~Continent,
  text = ~Country
) %>%
  layout(title = "GNI Per Capita in 1990, 2000, and 2021")

plotly 2 - graph

plotly 2 - code

gni_data %>%
  group_by(Continent) %>%
  summarise(total_gni = sum(GNI_2021, na.rm = TRUE)) %>%
  plot_ly(labels = ~Continent, values = ~total_gni, type = 'pie') %>%
  layout(title = 'GNI Share by Continent (2021)')

Statistics / Commentary

summary(gni_data$GNI_2021)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
##    731.8   4566.3  12306.3  20136.4  30027.3 146829.7        2

What this statistics shows a very high skewed distribution of income throughout the world. This shows that many countries are falling behind based on their economic status. Many countries fall below the average income which helps shows that there is a huge economic inequality when it comes to these major countries compared to smaller countries.

```