setwd('//Users//suy//Downloads//P_Data_Extract_From_World_Development_Indicators//')
female <- read.csv("female.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()
setwd('//Users//suy//Downloads//P_Data_Extract_From_World_Development_Indicators (1)')
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, y=percentage_ownership)) +
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
# 2 ## The ownership has been rising for Brazil and India whereas United
States has remained steady. ## Brazil has a higher percentage in Male
than Female and has remained that way throughout the years. ## India had
a historically high percetage for men but now they have the same rate
for both genders, rate for men has slightly decreased. ## Indian Female
rates have the highest growth among all data sets, jumping by around
38%.
setwd("/Users/suy/Downloads/Primary_Data_File")
primary <- read.csv(file = "primary.csv")
primary <- primary %>%
filter(Country.Name == "Nepal" | Country.Name == "China" | Country.Name == "Chile" | Country.Name == "Japan" | Country.Name == "Denmark")
primary <- primary[rel_col] %>%
rename("2014" = 2, "2017" = 3, "2021" = 4)
secondary <- read.csv(file = "secondary.csv")
secondary <- secondary %>%
filter(Country.Name == "Nepal" | Country.Name == "China" | Country.Name == "Chile" | Country.Name == "Japan" | Country.Name == "Denmark")
secondary <- secondary[rel_col] %>%
rename("2014" = 2, "2017" = 3, "2021" = 4)
transpose_p <- data.frame(t(primary[-1]))
colnames(transpose_p) <- primary[, 1]
transpose_p$Nepal = as.numeric(as.character(transpose_p$Nepal))
transpose_p$China = as.numeric(as.character(transpose_p$China))
transpose_p$Chile = as.numeric(as.character(transpose_p$Chile))
transpose_p$Japan = as.numeric(as.character(transpose_p$Japan))
transpose_p$Denmark = as.numeric(as.character(transpose_p$Denmark))
head(transpose_p)
## Chile China Denmark Japan Nepal
## 2014 36.68 72.82 100 83.66 29.62
## 2017 54.18 71.39 100 91.43 41.84
## 2021 68.85 83.02 100 94.10 51.00
transpose_s <- data.frame(t(secondary[-1]))
colnames(transpose_s) <- secondary[, 1]
transpose_s$Nepal = as.numeric(as.character(transpose_s$Nepal))
transpose_s$China = as.numeric(as.character(transpose_s$China))
transpose_s$Chile = as.numeric(as.character(transpose_s$Chile))
transpose_s$Japan = as.numeric(as.character(transpose_s$Japan))
transpose_s$Denmark = as.numeric(as.character(transpose_s$Denmark))
head(transpose_s)
## Chile China Denmark Japan Nepal
## 2014 71.31 89.84 100.00 99.67 51.94
## 2017 80.92 94.14 99.91 99.49 58.60
## 2021 93.03 97.21 100.00 99.22 63.30
transpose_p <- rename(transpose_p, "Chile_p" = 1, "China_p" = 2, "Denmark_p" = 3, "Japan_p" = 4, "Nepal_p" = 5)
transpose_s <- rename(transpose_s, "Chile_s" = 1, "China_s" = 2, "Denmark_s" = 3, "Japan_s" = 4, "Nepal_s" = 5)
head(transpose_p)
## Chile_p China_p Denmark_p Japan_p Nepal_p
## 2014 36.68 72.82 100 83.66 29.62
## 2017 54.18 71.39 100 91.43 41.84
## 2021 68.85 83.02 100 94.10 51.00
head(transpose_s)
## Chile_s China_s Denmark_s Japan_s Nepal_s
## 2014 71.31 89.84 100.00 99.67 51.94
## 2017 80.92 94.14 99.91 99.49 58.60
## 2021 93.03 97.21 100.00 99.22 63.30
transpose_p <- rownames_to_column(transpose_p, var="Year")
transpose_s <- rownames_to_column(transpose_s, var="Year")
acct_owner_by_education <- merge(x = transpose_p, y = transpose_s, by = "Year", all.x = TRUE)
head(acct_owner_by_education)
## Year Chile_p China_p Denmark_p Japan_p Nepal_p Chile_s China_s Denmark_s
## 1 2014 36.68 72.82 100 83.66 29.62 71.31 89.84 100.00
## 2 2017 54.18 71.39 100 91.43 41.84 80.92 94.14 99.91
## 3 2021 68.85 83.02 100 94.10 51.00 93.03 97.21 100.00
## Japan_s Nepal_s
## 1 99.67 51.94
## 2 99.49 58.60
## 3 99.22 63.30
gfg_plot <- ggplot(acct_owner_by_education, aes(x=year, y = percentage_ownership)) +
geom_line(aes(y = Chile_p), color = "black") +
geom_line(aes(y = Chile_s), color = "red") +
geom_line(aes(y = China_p), color = "green") +
geom_line(aes(y = China_s), color = "blue") +
geom_line(aes(y = Denmark_p), color = "purple") +
geom_line(aes(y = Denmark_s), color = "yellow") +
geom_line(aes(y = Japan_p), color = "chocolate") +
geom_line(aes(y = Japan_s), color = "violet") +
geom_line(aes(y = Nepal_p), color = "cyan") +
geom_line(aes(y = Nepal_s), color = "mediumvioletred")
gfg_plot