setwd("C:/Users/ava/Downloads/data110")
humanfreedom <- read.csv("humanfreedom.csv")Human Freedom
Introduction : The data set below is from cato institute : https://www.cato.org/
The data measures the state of human freedom in the world. This dataset aims to provide a broad measure of human freedom scores. The index covers various aspects of personal, civil, and economic freedom. This data set could be considered complete data due to several factors. The dataset includes data for numerous countries and regions, allowing for comparisons across different geographical areas and over a time period of ten years. Countries are scored and ranked based on their performance in each dimension of freedom. Scores typically range from 0 to 10, with higher scores indicating greater freedom. The overall Human Freedom Index score is an average of the personal and economic freedom scores. Therefore, this makes the data great for comparing the levels of personal, economic, and overall freedom across different countries and regions. And also to analyze how freedom has changed over time in specific countries or regions, which is what will be covered in this visualization.
Access Library package - Tidyverse
# loading "tiyverse" and "dyplr" also "viridis" for color
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.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── 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(tinytex)
library(dplyr)
library(viridis)Loading required package: viridisLite
Selected Data Women freedom score based on each region for each year
# selecting the column
selected_column <- humanfreedom |>
select(year , region , womens_freedom)Clean Data
# cleaning the Data
hf_clean <- na.omit(selected_column)Access Library package - Tidyverse
Average Women Freedom Score shown by Regions
# calculating Average of women's freedom of each region by using function summrize ,
#and grouping it by year and region
average_women_freedom <- hf_clean %>%
group_by(region, year) %>%
summarize(avg_freedom = mean(womens_freedom))%>%
filter(region != "Western Europe")`summarise()` has grouped output by 'region'. You can override using the
`.groups` argument.
p1 <- average_women_freedom |>
ggplot(
aes(x = year, y= avg_freedom)) +
# geom_line following geom point that shows the score for each year
geom_line(aes(color = region), size = 2) + geom_point( color = "black")+
# using "facet_wrap" to separate each region
facet_wrap(~region) +
labs(title = "Women's Freedom Scores by Region (2015-2018)",
y = "Women's Freedom Score",
x = "") +
# using scale_fill_viridis to give it color
scale_fill_viridis(discrete=TRUE) +
scale_color_viridis(discrete=TRUE) +
theme_grey()+
theme(axis.text.x = element_text(angle = 45, hjust = 1))Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
p1Essay : This graph depicts the scores for women’s freedom in various regions over a ten-year period. The dataset initially contained missing values for specific years, which had to be excluded for data cleaning. I used the “na.omit” function to ensure that the data for the visualization remained consistent. To present my visualization with clarity and coherence, I used “facet_wrap()” to organize the data into a cohesive series of panels that effectively demonstrated changes in women’s freedom scores across nine regions. In the final chart, each region is represented by a different color, and there is a table next to the visual that clarifies the color assignned for each region.
This visulazition highlighting several intriguing trends. Notably, regions like East Asia, North America, and Eastern Europe showed minimal change, whereas the Middle East experienced significant shifts, with unfortunate declines in women’s freedom. Upon examining political and social aspects in countries such as Iran, Iraq, and Afghanistan, it becomes evident that women’s freedoms are regrettably diminishing in the Middle East and North Africa. This underscores a pressing need for global action to foster a safer and more equitable environment for women worldwide