install.packages("remotes")
::install_github("vidonne/unhcrthemes") remotes
Gazzelloni F. (2023), Data Visualization: UN Woman
Data for this visualization is from the un.org, to download the data: https://population.un.org/wpp/Download/Standard/Fertility/.
The theme for the challenge is Theme Day: UN Woman and I chosen a package made by Cédric Vidonne, which provides a ggplot2 theme and a set of colour palettes for making charts and graphics based on UNHCR Data Visualization Guidelines.
To install the package:
Load necessary packages:
library(tidyverse)
library(scales)
library(unhcrthemes)
Download and load the data:
library(readxl)
<- read_excel("data/WPP2022_FERT_F04_BIRTHS_BY_5-YEAR_AGE_GROUPS_OF_MOTHER.xlsx",
df sheet = "Estimates",
skip = 16)
%>%names df
<- df%>%
df1 ::clean_names()%>%
janitorpivot_longer(cols = 13:20)%>%
select(region=region_subregion_country_or_area,
%>%
year,name,value)mutate(value2=as.numeric(value),
value2=round(value2),
name=gsub("x","",name),
name=gsub("_","-",name))%>%
rename(age=name) %>%
filter(!is.na(year))
%>%head;
df1%>%dim df1
164160 4
%>%summary() df1
options(scipen=999)
%>%
df1filter(region=="WORLD",
==2021) %>%
yearggplot(aes(x = age, y = value2)) +
geom_bar(stat = "identity", fill = "#0072C6") +
labs(
title = "World: Number of births classified by five-year age groups of mother",
subtitle="Data are presented in thousands (K)",
x = "Age category",
y = "Value",
caption="DataSource:Fertility standard projections (population.un.org)\n#30DayChartChallenge day24: Theme Day: UN Woman | DataViz: Federica Gazzelloni"
+
) scale_y_continuous(labels = label_number(suffix = "K", scale = 1e-3))+
::theme_unhcr() unhcrthemes
library(showtext)
showtext.auto(enable = FALSE)
ggsave("day_14_UNWoman.png",
bg="white",
width = 7,height = 5)