Human Freedom Index

Author

Christian Estrada

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.2     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.1.0     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(RColorBrewer)
setwd("C:/Users/chris/Downloads/DATA 110")
freedom <- read_csv("human_freedom_index2020.csv")
New names:
Rows: 1782 Columns: 113
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(3): ISO_code, countries, region dbl (110): ...1, year, hf_score, hf_rank,
hf_quartile, pf_rol_procedural, pf...
ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
Specify the column types or set `show_col_types = FALSE` to quiet this message.
• `` -> `...1`

I will be comparing the freedom levels of 5 different countries according to the human freedom index created by the Cato institute. According to the Cato institute, freedom is measured by personal freedoms (access to certain substances, sexual freedom, privacy, gun ownership, etc.) along with economic freedom (taxation, regulations, zoning laws, etc.) The 5 different countries I will be comparing are the United States, China, France, Switzerland, and Sudan.

freedom <- filter(
  freedom,
  countries == "United States" |
  countries == "China" | 
  countries == "France" |
  countries == "Switzerland" |
  countries == "Sudan"
)
freedom$overall_score <- (freedom$pf_score + freedom$ef_score) / 2

citation: R Core Team. (2023) R: a language and environment for statistical computing (Version 4.x) R foundation for statistical computing https://www.R-project.org

ggplot(freedom, aes(x = reorder(countries, pf_score), y = pf_score, fill = countries)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  scale_fill_brewer(palette = "Set2") +
  labs(
    title = "Personal Freedom Scores",
    caption = "Source: Cato Institute Human Freedom Index 2024", 
    x = "Country",
    y = "Personal Freedom Score"
  ) +
  theme_linedraw()
Warning: Removed 8 rows containing missing values or values outside the scale range
(`geom_bar()`).

ggplot(freedom, aes(x = reorder(countries, ef_score), y = ef_score, fill = countries)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  scale_fill_brewer(palette = "Set2") +
  labs(
    title = "Economic Freedom Scores",
    caption = "Source: Cato Institute Human Freedom Index 2024",
    x = "Country",
    y = "Economic Freedom Score"
  ) +
  theme_void() 
Warning: Removed 8 rows containing missing values or values outside the scale range
(`geom_bar()`).

ggplot(freedom, aes(x = reorder(countries, overall_score), y = overall_score, fill = countries)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  scale_fill_brewer(palette = "Set2") +
  labs(
    title = "Overall Freedom Scores (Average of Economic + Personal)",
    caption = "Source: Cato Institute Human Freedom Index 2024",
    x = "Country",
    y = "Overall Freedom Score"
  ) +
  theme_classic()
Warning: Removed 8 rows containing missing values or values outside the scale range
(`geom_bar()`).

The original dataset had hundreds of countries which I felt would have been too messy and incoherent to turn into a simple plot, so in order to “clean” the data set I filtered out every country except for the five I chose, having the countries variable only count for the select five. The visualizations represent the scores for each country along the freedom index and represent their contrast. Unsurprisingly, Sudan scored incredibly low and was far lower on every scale compared to the other four. I was surprised to see China have a score above 50 in both economic freedom and personal freedom, due to it being relatively known as a very authoritarian state that favors a command economy. What I would have liked to show were a few extra countries like Russia and Afghanistan, but I couldn’t get them to work with the graphs as they simply didn’t show up (originally the project had seven countries), so I left them out and worked with the five that did work.