.
The code to change the y axis is aes(x=year,y= percentage_ownership).
In India both male and female ownership were on the rise from 2014-2017, with male ownership being higher than female ownership from 2014-2020. After 2017 male ownership was slightly decreasing, while female ownership remained stagnant. In Brazil, male ownership started off higher than female ownership. Both genders saw gradual increases from 2014-2017, however after 2017 both genders saw a noticeable jump in ownership, which has persisted past 2020. In America women have a higher ownership percentage than men. Women’s ownerhip was slightly decreasing up until 2017, where it started to experience gradual increases. Male ownership slighly increased up until 2017, to which it then started decreasing slightly.
3.If certain years are disregarded then one could say that a country has experienced an increase. For examples disregarding from 2017 onwards India has made a substantial rise in ownership across both genders. If you focus on a particular country and gender combination, then you are able to cherry pick and says things like, “American ownership has been on the rise since 2017, even though male ownership decreased during that period.
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.4.4 ✔ 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
setwd("C:/Users/adede/Downloads/P_Data_Extract_From_World_Development_Indicators (6)")
primary <- read.csv("primary.csv")
is.data.frame(primary)
## [1] TRUE
head(primary)
## Series.Name
## 1 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 2 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 3 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 4 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 5 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 6 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## Series.Code Country.Name Country.Code X1990..YR1990. X2000..YR2000.
## 1 FX.OWN.TOTL.PL.ZS Afghanistan AFG .. ..
## 2 FX.OWN.TOTL.PL.ZS Albania ALB .. ..
## 3 FX.OWN.TOTL.PL.ZS Algeria DZA .. ..
## 4 FX.OWN.TOTL.PL.ZS American Samoa ASM .. ..
## 5 FX.OWN.TOTL.PL.ZS Andorra AND .. ..
## 6 FX.OWN.TOTL.PL.ZS Angola AGO .. ..
## X2013..YR2013. X2014..YR2014. X2015..YR2015. X2016..YR2016. X2017..YR2017.
## 1 .. 4.83 .. .. 8.89
## 2 .. 24.01 .. .. 27.5
## 3 .. 48.35 .. .. 38.95
## 4 .. .. .. .. ..
## 5 .. .. .. .. ..
## 6 .. 14.35 .. .. ..
## X2018..YR2018. X2019..YR2019. X2020..YR2020. X2021..YR2021. X2022..YR2022.
## 1 .. .. .. 5.18 ..
## 2 .. .. .. 34.36 ..
## 3 .. .. .. 38.99 ..
## 4 .. .. .. .. ..
## 5 .. .. .. .. ..
## 6 .. .. .. .. ..
primary <- primary %>%
filter(Country.Name == "Afghanistan" | Country.Name == "Albania" | Country.Name == "Algeria" | Country.Name == "Colombia" | Country.Name == "Nigeria")
head(primary)
## Series.Name
## 1 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 2 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 3 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 4 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## 5 Account ownership at a financial institution or with a mobile-money-service provider, primary education or less (% of population ages 15+)
## Series.Code Country.Name Country.Code X1990..YR1990. X2000..YR2000.
## 1 FX.OWN.TOTL.PL.ZS Afghanistan AFG .. ..
## 2 FX.OWN.TOTL.PL.ZS Albania ALB .. ..
## 3 FX.OWN.TOTL.PL.ZS Algeria DZA .. ..
## 4 FX.OWN.TOTL.PL.ZS Colombia COL .. ..
## 5 FX.OWN.TOTL.PL.ZS Nigeria NGA .. ..
## X2013..YR2013. X2014..YR2014. X2015..YR2015. X2016..YR2016. X2017..YR2017.
## 1 .. 4.83 .. .. 8.89
## 2 .. 24.01 .. .. 27.5
## 3 .. 48.35 .. .. 38.95
## 4 .. 19.62 .. .. 32.78
## 5 .. 28.08 .. .. 16.05
## X2018..YR2018. X2019..YR2019. X2020..YR2020. X2021..YR2021. X2022..YR2022.
## 1 .. .. .. 5.18 ..
## 2 .. .. .. 34.36 ..
## 3 .. .. .. 38.99 ..
## 4 .. .. .. 48.08 ..
## 5 .. .. .. 25.8 ..
colnames(primary)
## [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(primary)=="Country.Name" | colnames(primary)== "X2014..YR2014." | colnames(primary)== "X2017..YR2017." | colnames(primary) == "X2021..YR2021." )
rel_col
## [1] 3 8 11 15
primary <- primary[rel_col] %>% rename("2014" = 2, "2017" = 3, "2021" = 4)
head(primary)
## Country.Name 2014 2017 2021
## 1 Afghanistan 4.83 8.89 5.18
## 2 Albania 24.01 27.5 34.36
## 3 Algeria 48.35 38.95 38.99
## 4 Colombia 19.62 32.78 48.08
## 5 Nigeria 28.08 16.05 25.8
transpose_f <- data.frame(t(primary[-1]))
colnames(transpose_f) <- primary[, 1]
head(transpose_f)
## Afghanistan Albania Algeria Colombia Nigeria
## 2014 4.83 24.01 48.35 19.62 28.08
## 2017 8.89 27.5 38.95 32.78 16.05
## 2021 5.18 34.36 38.99 48.08 25.8
print(sapply(transpose_f, class))
## Afghanistan Albania Algeria Colombia Nigeria
## "character" "character" "character" "character" "character"
transpose_f$Afghanistan = as.numeric(transpose_f$Afghanistan)
transpose_f$Albania = as.numeric(transpose_f$Albania)
transpose_f$Algeria = as.numeric(transpose_f$Algeria)
transpose_f$Colombia = as.numeric(transpose_f$Colombia)
transpose_f$Nigeria = as.numeric(transpose_f$Nigeria)
head(transpose_f)
## Afghanistan Albania Algeria Colombia Nigeria
## 2014 4.83 24.01 48.35 19.62 28.08
## 2017 8.89 27.50 38.95 32.78 16.05
## 2021 5.18 34.36 38.99 48.08 25.80
transpose_f %>%
summarise(across(c(Afghanistan, Albania, Algeria, Colombia, Nigeria), list(mean=mean, sd=sd)))
## Afghanistan_mean Afghanistan_sd Albania_mean Albania_sd Algeria_mean
## 1 6.3 2.249822 28.62333 5.265647 42.09667
## Algeria_sd Colombia_mean Colombia_sd Nigeria_mean Nigeria_sd
## 1 5.415582 33.49333 14.2434 23.31 6.389859
year <- c(2014, 2017,2021)
ggplot(data=transpose_f, aes(x=year, y= Albania, group = 1)) +
geom_line()+
geom_point()
setwd("C:/Users/adede/Downloads/P_Data_Extract_From_World_Development_Indicators (7)")
secondary <- read.csv(file = "secondary.csv")
secondary <- secondary %>%
filter(Country.Name == "Afghanistan" | Country.Name == "Albania" | Country.Name == "Algeria" | Country.Name == "Colombia" | Country.Name == "Nigeria")
secondary <- secondary[rel_col] %>%
rename("2014" = 2, "2017" = 3, "2021" = 4)
transpose_m <- data.frame(t(secondary[-1]))
colnames(transpose_m) <- secondary[, 1]
transpose_m$Afghanistan = as.numeric(as.character(transpose_m$Afghanistan))
transpose_m$Albania = as.numeric(as.character(transpose_m$Albania))
transpose_m$Algeria = as.numeric(as.character(transpose_m$Algeria))
transpose_m$Colombia = as.numeric(as.character(transpose_m$Colombia))
transpose_m$Nigeria = as.numeric(as.character(transpose_m$Nigeria))
head(transpose_m)
## Afghanistan Albania Algeria Colombia Nigeria
## 2014 22.60 56.22 55.32 46.13 56.03
## 2017 30.56 55.83 48.96 53.34 59.30
## 2021 23.40 56.50 46.23 64.66 65.20
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, "Nigeria" = 11)
head(acct_owner_by_gender)
## Year Afghanistan.x Albania.x Algeria.x Colombia.x Nigeria.x Afghanistan.y
## 1 2014 22.60 56.22 55.32 46.13 56.03 4.83
## 2 2017 30.56 55.83 48.96 53.34 59.30 8.89
## 3 2021 23.40 56.50 46.23 64.66 65.20 5.18
## Albania.y Algeria.y Colombia.y Nigeria
## 1 24.01 48.35 19.62 28.08
## 2 27.50 38.95 32.78 16.05
## 3 34.36 38.99 48.08 25.80
gfg_plot <- ggplot(acct_owner_by_gender, aes(x=year)) +
geom_line(aes(y = Afghanistan.x), color = "black") +
geom_line(aes(y = Afghanistan.y), color = "red") +
geom_line(aes(y = Algeria.x), color = "green") +
geom_line(aes(y = Algeria.y), color = "blue") +
geom_line(aes(y = Albania.x), color = "purple") +
geom_line(aes(y = Albania.y), color = "violet") +
geom_line(aes(y = Colombia.x), color = "yellow") +
geom_line(aes(y = Colombia.y), color = "turquoise") +
geom_line(aes(y = Nigeria.x), color = "orange") +
geom_line(aes(y = Nigeria), color = "maroon")
gfg_plot
.x is secondary and .y is primary For Nigeria, Nigeria.x is secondary
and Nigeria is primary