#PROJECT 1
##SETTING UP CODE FOR THE PROJECT
setwd("/Users/dpatel78/Desktop")
female <- read.csv("female.csv")
male <- read.csv("male.csv")
is.data.frame(female)
## [1] TRUE
head(female)
## Series.Name
## 1 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## 2 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## 3 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## 4 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## 5 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## 6 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## Series.Code Country.Name Country.Code X1990..YR1990. X2000..YR2000.
## 1 FX.OWN.TOTL.FE.ZS Afghanistan AFG .. ..
## 2 FX.OWN.TOTL.FE.ZS Albania ALB .. ..
## 3 FX.OWN.TOTL.FE.ZS Algeria DZA .. ..
## 4 FX.OWN.TOTL.FE.ZS American Samoa ASM .. ..
## 5 FX.OWN.TOTL.FE.ZS Andorra AND .. ..
## 6 FX.OWN.TOTL.FE.ZS Angola AGO .. ..
## X2013..YR2013. X2014..YR2014. X2015..YR2015. X2016..YR2016. X2017..YR2017.
## 1 .. 3.81 .. .. 7.16
## 2 .. 33.59 .. .. 38.1
## 3 .. 40.07 .. .. 29.27
## 4 .. .. .. .. ..
## 5 .. .. .. .. ..
## 6 .. 22.33 .. .. ..
## X2018..YR2018. X2019..YR2019. X2020..YR2020. X2021..YR2021. X2022..YR2022.
## 1 .. .. .. 4.7 ..
## 2 .. .. .. 45.69 ..
## 3 .. .. .. 31.19 ..
## 4 .. .. .. .. ..
## 5 .. .. .. .. ..
## 6 .. .. .. .. ..
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.0 ✔ 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
female <- female %>%
filter(Country.Name == "Brazil" | Country.Name == "India" |
Country.Name == "United States")
head(female)
## Series.Name
## 1 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## 2 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## 3 Account ownership at a financial institution or with a mobile-money-service provider, female (% of population ages 15+)
## Series.Code Country.Name Country.Code X1990..YR1990. X2000..YR2000.
## 1 FX.OWN.TOTL.FE.ZS Brazil BRA .. ..
## 2 FX.OWN.TOTL.FE.ZS India IND .. ..
## 3 FX.OWN.TOTL.FE.ZS United States USA .. ..
## X2013..YR2013. X2014..YR2014. X2015..YR2015. X2016..YR2016. X2017..YR2017.
## 1 .. 64.77 .. .. 67.51
## 2 .. 43.13 .. .. 76.64
## 3 .. 94.8 .. .. 92.69
## X2018..YR2018. X2019..YR2019. X2020..YR2020. X2021..YR2021. X2022..YR2022.
## 1 .. .. .. 80.87 ..
## 2 .. .. .. 77.55 ..
## 3 .. .. .. 96.79 ..
colnames(female)
## [1] "Series.Name" "Series.Code" "Country.Name" "Country.Code"
## [5] "X1990..YR1990." "X2000..YR2000." "X2013..YR2013." "X2014..YR2014."
## [9] "X2015..YR2015." "X2016..YR2016." "X2017..YR2017." "X2018..YR2018."
## [13] "X2019..YR2019." "X2020..YR2020." "X2021..YR2021." "X2022..YR2022."
rel_col <- which(colnames(female)=="Country.Name" | colnames(female)== "X2014..YR2014." | colnames(female)== "X2017..YR2017." | colnames(female) == "X2021..YR2021." )
rel_col
## [1] 3 8 11 15
female <- female[rel_col] %>% rename("2014" = 2, "2017" = 3, "2021" = 4)
head(female)
## Country.Name 2014 2017 2021
## 1 Brazil 64.77 67.51 80.87
## 2 India 43.13 76.64 77.55
## 3 United States 94.8 92.69 96.79
transpose_f <- data.frame(t(female[-1]))
colnames(transpose_f) <- female[, 1]
head(transpose_f)
## Brazil India United States
## 2014 64.77 43.13 94.8
## 2017 67.51 76.64 92.69
## 2021 80.87 77.55 96.79
print(sapply(transpose_f, class))
## Brazil India United States
## "character" "character" "character"
transpose_f$Brazil = as.numeric(transpose_f$Brazil)
transpose_f$India = as.numeric(transpose_f$India)
transpose_f$"United States" = as.numeric(transpose_f$"United States")
head(transpose_f)
## Brazil India United States
## 2014 64.77 43.13 94.80
## 2017 67.51 76.64 92.69
## 2021 80.87 77.55 96.79
transpose_f <- transpose_f %>% mutate_if(is.numeric, as.character)
head(transpose_f)
## Brazil India United States
## 2014 64.77 43.13 94.8
## 2017 67.51 76.64 92.69
## 2021 80.87 77.55 96.79
transpose_f <- transpose_f %>% mutate_if(is.character, as.numeric)
head(transpose_f)
## Brazil India United States
## 2014 64.77 43.13 94.80
## 2017 67.51 76.64 92.69
## 2021 80.87 77.55 96.79
summarise_each(transpose_f, list(mean))
## Warning: `summarise_each()` was deprecated in dplyr 0.7.0.
## ℹ Please use `across()` instead.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Brazil India United States
## 1 71.05 65.77333 94.76
transpose_f %>%
summarise(across(c(Brazil, India, "United States"), list(mean=mean, sd=sd)))
## Brazil_mean Brazil_sd India_mean India_sd United States_mean United States_sd
## 1 71.05 8.614012 65.77333 19.61498 94.76 2.050293
year <- c(2014, 2017,2021)
ggplot(data=transpose_f, aes(x=year, y=India, group=1)) +
geom_line()+
geom_point()

male <- read.csv(file = "male.csv")
male <- male %>%
filter(Country.Name == "Brazil" | Country.Name == "India" | Country.Name == "United States")
male <- male[rel_col] %>%
rename("2014" = 2, "2017" = 3, "2021" = 4)
transpose_m <- data.frame(t(male[-1]))
colnames(transpose_m) <- male[, 1]
transpose_m$Brazil = as.numeric(as.character(transpose_m$Brazil))
transpose_m$India = as.numeric(as.character(transpose_m$India))
transpose_m$"United States" = as.numeric(as.character((transpose_m$"United States")))
head(transpose_m)
## Brazil India United States
## 2014 71.69 62.76 92.36
## 2017 72.85 83.01 93.57
## 2021 87.05 77.51 93.09
transpose_m <- rename(transpose_m, "Brazil_m" = 1, "India_m" = 2, "United_States_m" = 3)
head(transpose_m)
## Brazil_m India_m United_States_m
## 2014 71.69 62.76 92.36
## 2017 72.85 83.01 93.57
## 2021 87.05 77.51 93.09
transpose_m <- rownames_to_column(transpose_m, var="Year")
transpose_f <- rownames_to_column(transpose_f, var="Year")
acct_owner_by_gender <- merge(x = transpose_m, y = transpose_f, by = "Year", all.x = TRUE)
acct_owner_by_gender <- rename(acct_owner_by_gender, "United_States" = 7)
head(acct_owner_by_gender)
## Year Brazil_m India_m United_States_m Brazil India United_States
## 1 2014 71.69 62.76 92.36 64.77 43.13 94.80
## 2 2017 72.85 83.01 93.57 67.51 76.64 92.69
## 3 2021 87.05 77.51 93.09 80.87 77.55 96.79
gfg_plot <- ggplot(acct_owner_by_gender, aes(x=year)) +
geom_line(aes(y = India), color = "black") +
geom_line(aes(y = India_m), color = "red") +
geom_line(aes(y = Brazil), color = "green") +
geom_line(aes(y = Brazil_m), color = "blue") +
geom_line(aes(y = United_States), color = "purple") +
geom_line(aes(y = United_States_m), color = "violet")
gfg_plot

#PART 1 - CLEANING UP THE FINAL PLOT
gfg_plot <- ggplot(acct_owner_by_gender, aes(x = year)) +
geom_line(aes(y = India), color = "black") +
geom_line(aes(y = India_m), color = "red") +
geom_line(aes(y = Brazil), color = "green") +
geom_line(aes(y = Brazil_m), color = "blue") +
geom_line(aes(y = United_States), color = "purple") +
geom_line(aes(y = United_States_m), color = "violet") +
labs(y = "Percentage Ownership")
gfg_plot

#PART 2 - DRAWING CONCLUSIONS
###GENERAL OBSERVATION
####Based on the graph provided , it can be observed that the percentage
####ownership in the United States is much more than both of India and Brazil.
####In the graph it can be seen that India starts of at the lowest , however
####it sees immense growth whilst still remaning below that of Brazil
###UNITED STATES
####Based on the graph provided , it can be observed that in the United States,
####both female and male ownership have remained relatively equal over time, and
####and above the 90% mark over the period of 2014-2020.
###INDIA
####Based on the graph provided , it can be observed that in India , the male
####population had a relatively higher percentage ownership than that of female
####population during the priod of 2014-2017 . However , in the period of 2017-
####2021 , both the female and male population had almost the same percentage
####ownership , leveling at about 85%.
###BRAZIL
####Based on the graph provided , it can be observed that in Brazil ,
####both female and male population have seen an increase in the percentage
####ownership how the female ownership is still below that of male percentage
####ownership.
###PART 3 - CHERRY PICKING
####In the context of India, it can be observed that there's a trend of
####increasing percentage ownerships when the previous year is excluded from
####consideration. In the case of Brazil, there's a consistent rise in
####percentage ownerships over time, unaffected by disregarding any specific
####year.Conversely, in the US, the percentage ownerships exhibit minimal
####fluctuation, maintaining a relatively constant pattern. Additionally,
####regardless of gender, the trends in ownership percentages remain consistent.
###PART 4 - SUMMARIZING THE DATA YOURSELF
setwd("/Users/dpatel78/Desktop")
primary_ed <- read.csv(file = "first_file.csv")
primary_ed <- primary_ed %>%
filter(Country.Name == "Algeria" | Country.Name == "Argentina" | Country.Name == "Belgium" | Country.Name == "France" | Country.Name == "Germany")
primary_ed <- primary_ed[rel_col] %>%
rename("2014" = 2, "2017" = 3, "2021" = 4)
transpose_p <- data.frame(t(primary_ed[-1]))
colnames(transpose_p) <- primary_ed[, 1]
transpose_p$Algeria = as.numeric(as.character(transpose_p$Algeria))
transpose_p$Argentina = as.numeric(as.character(transpose_p$Argentina))
transpose_p$Belgium = as.numeric(as.character(transpose_p$Belgium))
transpose_p$France = as.numeric(as.character(transpose_p$France))
transpose_p$Germany = as.numeric(as.character(transpose_p$Germany))
head(transpose_p)
## Algeria Argentina Belgium France Germany
## 2014 55.32 48.90 97.85 97.26 98.80
## 2017 48.96 52.28 98.84 97.23 99.30
## 2021 46.23 79.69 99.28 99.76 99.97
transpose_p <- rename(transpose_p, "Algeria" = 1, "Argentina" = 2, "Belgium" = 3 , "France"=4 , "Germany"=5)
head(transpose_p)
## Algeria Argentina Belgium France Germany
## 2014 55.32 48.90 97.85 97.26 98.80
## 2017 48.96 52.28 98.84 97.23 99.30
## 2021 46.23 79.69 99.28 99.76 99.97
secondary_ed <- read.csv(file = "spya.csv")
secondary_ed <- secondary_ed %>%
filter(Country.Name == "Algeria" | Country.Name == "Argentina" | Country.Name == "Belgium" | Country.Name == "France" | Country.Name == "Germany")
secondary_ed <- secondary_ed[rel_col] %>%
rename("2014" = 2, "2017" = 3, "2021" = 4)
transpose_s <- data.frame(t(secondary_ed[-1]))
colnames(transpose_s) <- secondary_ed[, 1]
transpose_s$Algeria = as.numeric(as.character(transpose_s$Algeria))
transpose_s$Argentina = as.numeric(as.character(transpose_s$Argentina))
transpose_s$Belgium = as.numeric(as.character(transpose_s$Belgium))
transpose_s$France = as.numeric(as.character(transpose_s$France))
transpose_s$Germany = as.numeric(as.character(transpose_s$Germany))
head(transpose_s)
## Algeria Argentina Belgium France Germany
## 2014 48.35 52.27 100.00 83.36 97.64
## 2017 38.95 43.05 100.00 79.82 100.00
## 2021 38.99 57.10 93.81 95.87 100.00
transpose_s <- rename(transpose_s, "Algeria_m" = 1, "Argentina_m" = 2, "Belgium_m" = 3 , "France_m"=4 , "Germany_m"=5)
head(transpose_s)
## Algeria_m Argentina_m Belgium_m France_m Germany_m
## 2014 48.35 52.27 100.00 83.36 97.64
## 2017 38.95 43.05 100.00 79.82 100.00
## 2021 38.99 57.10 93.81 95.87 100.00
transpose_p <- rownames_to_column(transpose_p, var="Year")
transpose_s <- rownames_to_column(transpose_s, var="Year")
acct_owner_by_ed_level <- merge(x = transpose_p, y = transpose_s, by = "Year", all.x = TRUE)
acct_owner_by_ed_level <- rename(acct_owner_by_ed_level, "Algeria_m" = 7)
head(acct_owner_by_ed_level)
## Year Algeria Argentina Belgium France Germany Algeria_m Argentina_m Belgium_m
## 1 2014 55.32 48.90 97.85 97.26 98.80 48.35 52.27 100.00
## 2 2017 48.96 52.28 98.84 97.23 99.30 38.95 43.05 100.00
## 3 2021 46.23 79.69 99.28 99.76 99.97 38.99 57.10 93.81
## France_m Germany_m
## 1 83.36 97.64
## 2 79.82 100.00
## 3 95.87 100.00
gfg_plot <- ggplot(acct_owner_by_ed_level, aes(x = Year)) +
geom_line(aes(y = Algeria), color = "darkorange3", group = 1) +
geom_line(aes(y = Algeria_m), color = "darkorange2", group = 1) +
geom_line(aes(y = Argentina), color = "darkorchid4", group = 1) +
geom_line(aes(y = Argentina_m), color = "darkorchid3", group = 1) +
geom_line(aes(y = Belgium), color = "deeppink4", group = 1) +
geom_line(aes(y = Belgium_m), color = "deeppink3", group = 1) +
geom_line(aes(y = France), color = "olivedrab4", group = 1) +
geom_line(aes(y = France_m), color = "olivedrab3", group = 1) +
geom_line(aes(y = Germany), color = "purple4", group = 1) +
geom_line(aes(y = Germany_m), color = "purple3", group = 1) +
labs(y = "Percentage Ownership")
gfg_plot

####GENERAL ANALYSIS
####The analysis reveals diverse trends in account ownership across countries
####and education levels. Algeria experiences a concerning decline in ownership,
####particularly pronounced in primary education, highlighting the need for
####intervention. Argentina shows a significant increase in ownership, notably
####in secondary education, suggesting successful accessibility efforts. Belgium
####presents an unusual pattern where secondary education starts lower than
####primary education in ownership, with primary education showing a slight
####decline over time while secondary education steadily rises. France and
####Germany both exhibit consistent growth in ownership across primary and
####secondary education, indicating stable financial inclusion efforts. These
####insights underscore the importance of tailored strategies to address varying
####levels of financial inclusion globally.
####ANALYSIS BY COUNTRY
#####ALGERIA
######For Algeria , we can see that the account ownership is rather less since
######it is less than 55% for both secondary and primary education . A rather
#####observation is than instead of increasing the account ownership decreases
#####overtime rather an increase , and the decrease is rather steep decreasing
#####from about 47% to about 39% for primary education .
gfg_plot <- ggplot(acct_owner_by_ed_level, aes(x = Year)) +
geom_line(aes(y = Algeria), color = "darkorange3", group = 1) +
geom_line(aes(y = Algeria_m), color = "darkorange2", group = 1) +
labs(y = "Percentage Ownership")
gfg_plot

#####ARGENTINA
######For Argentina , we can see that the account ownership starts at 50% ,
######however from 2017 , we can see a drastic increase in the ownership for
######both secondary and primary education , with secondary education reaching
######80% , and primary education reaching just about 58% percent.
gfg_plot <- ggplot(acct_owner_by_ed_level, aes(x = Year)) +
geom_line(aes(y = Argentina), color = "darkorchid4", group = 1) +
geom_line(aes(y = Argentina_m), color = "darkorchid3", group = 1) +
labs(y = "Percentage Ownership")
gfg_plot

#####BELGIUM
######For Belgium , we can see a strang occurence where the secondary education
######starts of less than the primary education , and the account ownership for
######primary education starting at 100% and then lowering down to about 94%,
######whereas the secondary education increases at a steady rate from about 98%
######to nearly 99%.
gfg_plot <- ggplot(acct_owner_by_ed_level, aes(x = Year)) +
geom_line(aes(y = Belgium), color = "deeppink4", group = 1) +
geom_line(aes(y = Belgium_m), color = "deeppink3", group = 1) +
labs(y = "Percentage Ownership")
gfg_plot

#####FRANCE
#####For France ,we can see a that the account ownership for both secondary start
#####off from around 96% and steadily grow to about 100% , whereas primary
#####education start off from around 84% and drastically grow to about 96%.
gfg_plot <- ggplot(acct_owner_by_ed_level, aes(x = Year)) +
geom_line(aes(y = France), color = "olivedrab4", group = 1) +
geom_line(aes(y = France_m), color = "olivedrab3", group = 1) +
labs(y = "Percentage Ownership")
gfg_plot

####GERMANY
#####For Germany , we can see that account ownership for both primary and
#####secondary education start off higher than other countries , where secondary
#####starts off from about 99% and reaches 100% steadily , whereas for primary
#####we see a drastic increase from about 97.5% to about 100%.
gfg_plot <- ggplot(acct_owner_by_ed_level, aes(x = Year)) +
geom_line(aes(y = Germany), color = "purple4", group = 1) +
geom_line(aes(y = Germany_m), color = "purple3", group = 1) +
labs(y = "Percentage Ownership")
gfg_plot
