In this note, we study how to construct, or recreate charts presented in World Inequality Report. We focus on the Executive Summary, however, we hope that you can study the report in more detail using the original data provided in the site.
There is an R package to make it easier to download the data.
First, create a new project using R Studio and create a
data
folder in it by running the following code. It is
better to set Lang = "en"
as you can find a resolution
easily by posting the error message.
Sys.setenv(LANG = "en")
dir.create("./data")
library(tidyverse)
library(readxl)
library(DT)
url_summary <- "https://wir2022.wid.world/www-site/uploads/2022/03/WIR2022TablesFigures-Summary.xlsx"
download.file(
url = url_summary,
destfile = "./data/WIR2022TablesFigures-Summary.xlsx",
mode = "wb")
Note:
mode = "wb"
is for binary files.data
folder in your Project folder.As Mac uses resource files, the following simple code works as well.
download.file(url = url_summary,
destfile = "data/WIR2022TablesFigures-Summary.xlsx")
summary_sheets <- excel_sheets("data/WIR2022TablesFigures-Summary.xlsx")
summary_sheets
[1] "Index" "F1" "F2" "F3" "F4"
[6] "F5." "F6" "F7" "F8" "F9"
[11] "F10" "F11" "F12" "F13" "F14"
[16] "F15" "T1" "data-F1" "data-F2" "data-F3"
[21] "data-F4" "data-F5" "data-F6" "data-F7" "data-F8"
[26] "data-F9" "data-F10" "data-F11" "data-F12" "data-F13."
[31] "data-F14." "data-F15"
sheet = "Index"
by
sheet = 1
. However, the sheet number stays the same if a
sheet is deleted. So it is safer to use the sheet name.df_index <- read_excel("data/WIR2022TablesFigures-Summary.xlsx", sheet = "Index")
df_index
df_f1 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F1")
New names:
...1
to its name, and returns a message:
New names:.
df_f1
df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "group", values_to = "value") %>%
ggplot(aes(x = cat, y = value, fill = group)) +
geom_col(position = "dodge") +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
geom_text(aes(x = cat, y = value, group = group, label = scales::label_percent(accuracy=1)(value)), vjust = -0.08,
position = position_dodge(0.9)) +
labs(title = "Figure 1. Global income and wealth inequality, 2021",
x = "", y = "Share of total income or wealth", fill = "")
Interpretation: The global bottom 50% captures 8.5%
of total income measured at Purchasing Power Parity (PPP). The global
bottom 50% owns 2% of wealth (at Purchasing Power Parity). The global
top 10% owns 76% of total Household wealth and captures 52% of total
income in 2021. Note that top wealth holders are not necessarily top
income holders. Incomes are measured after the operation of pension and
unemployment systems and before taxes and transfers.
Sources and series: wir2022.wid.world/methodology.
pivot_longer
.pivot_longer
is:
pivot_longer(cols, names_to = "group", values_to = "value")
,
and cols
is the columns to pivot into a longer format.
Hence, in this case, cols = 2:4
or cols = -1
,
i.e., except the first column.df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "group", values_to = "value")
ggplot2
to draw a chart.df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "level", values_to = "value") %>%
ggplot(aes(x = cat, y = value, fill = level)) +
geom_col()
position = dodge
.df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "group", values_to = "value") %>%
ggplot(aes(x = cat, y = value, fill = group)) +
geom_col(position = "dodge")
scale_y_continuous(labels = c("0%", "20%", "40%", "60%", "80%"))
does the same.df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "group", values_to = "value") %>%
ggplot(aes(x = cat, y = value, fill = group)) +
geom_col(position = "dodge") +
scale_y_continuous(labels = scales::percent_format(accuracy = 1))
df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "group", values_to = "value") %>%
ggplot(aes(x = cat, y = value, fill = group)) +
geom_col(position = "dodge") +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 1. Global income and wealth inequality, 2021",
x = "", y = "Share of total income or wealth", fill = "")
df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "group", values_to = "value") %>%
ggplot(aes(x = cat, y = value, fill = group)) +
geom_col(position = "dodge") +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
geom_text(aes(x = cat, y = value, group = group, label = scales::label_percent(accuracy=1)(value)),
position = position_dodge(0.9)) +
labs(title = "Figure 1. Global income and wealth inequality, 2021",
x = "", y = "Share of total income or wealth", fill = "")
vjust
.df_f1 %>% select(cat = ...1, 2:4) %>%
pivot_longer(2:4, names_to = "group", values_to = "value") %>%
ggplot(aes(x = cat, y = value, fill = group)) +
geom_col(position = "dodge") +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
geom_text(aes(x = cat, y = value, group = group, label = scales::label_percent(accuracy=1)(value)), vjust = 0,
position = position_dodge(width = 0.9)) +
labs(title = "Figure 1. Global income and wealth inequality, 2021",
x = "", y = "Share of total income or wealth", fill = "")
df_f3 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F3")
df_f3
map0<-map_data("world")
map0$region[map0$region=="Democratic Republic of the Congo"]<-"DR Congo"
map0$region[map0$region=="Republic of Congo"]<-"Congo"
map0$region[map0$region=="Ivory Coast"]<-"Cote dIvoire"
map0$region[map0$region=="Vietnam"]<-"Viet Nam"
map0$region[map0$region=="Russia"]<-"Russian Federation"
map0$region[map0$region=="South Korea"]<-"Korea"
map0$region[map0$region=="UK"]<-"United Kingdom"
map0$region[map0$region=="Brunei"]<-"Brunei Darussalam"
map0$region[map0$region=="Laos"]<-"Lao PDR"
map0$region[map0$region=="Cote dIvoire"]<-"Cote d'Ivoire"
map0$region[map0$region=="Cape Verde"]<- "Cabo Verde"
map0$region[map0$region=="Syria"]<- "Syrian Arab Republic"
map0$region[map0$region=="Trinidad"]<- "Trinidad and Tobago"
map0$region[map0$region=="Tobago"]<- "Trinidad and Tobago"
df_f3 %>%
mutate(`Top 10 Bottom 50 Ratio` = cut(T10B50,breaks = c(5, 12, 13, 16, 19,140), include.lowest = FALSE)) %>%
ggplot(aes(map_id = Country)) + geom_map(aes(fill = `Top 10 Bottom 50 Ratio`), map = map0) + expand_limits(x = world_map$long, y = world_map$lat) +
labs(title = "Figure 3. Top 10/Bottom 50 income gaps across the world, 2021",
x = "", y = "", fill = "Top 10/Bottom 50 ratio") +
theme(legend.position="bottom",
axis.text.x=element_blank(), axis.ticks.x=element_blank(),
axis.text.y=element_blank(), axis.ticks.y=element_blank()) +
scale_fill_brewer(palette='YlOrRd')
Interpretation: In Brazil, the bottom 50% earns 29 times less than the top 10%. The value is 7 in France. Income is measured after pension and unemployment payments and benefits received by individuals but before other taxes they pay and transfers they receive. Source and series: wir2022.wid.world/methodology.
df_f3 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F3")
df_f3
map_data("world")
data attached to the
tidyverse
package. Let us look at the data first.world_map <- map_data("world")
datatable(world_map)
Warning: It seems your data is too big for client-side DataTables. You may consider server-side processing: https://rstudio.github.io/DT/server.htmlWarning: It seems your data is too big for client-side DataTables. You may consider server-side processing: https://rstudio.github.io/DT/server.html
ggplot
. We
use Country
for map_id
and T10B50
for numerical data. Since world_map
data contains
long
and lat
of each region, we assign them as
expand_limit
.df_f3 %>%
ggplot(aes(map_id = Country)) +
geom_map(aes(fill = `T10B50`), map = world_map) +
expand_limits(x = world_map$long, y = world_map$lat)
The region name and the country name may be different in two
datasets world_map
and df_f3
. Let us take care
of the first issue.
To search names, we use DT::datatable
, i.e.,
datatable
in the DT
package.
datatable(df_f3)
Search for ‘russia’ and ‘congo’, we find that
world_map
world_map
world_map
There are at least three ways to change the entries.
The following is a method to use Base R.
df_f3_rev$Country[df_f3_rev$Country == "Russian Federation"] <- "Russia": If the entry of the column
Countryin the data frame
df_f3_revmatches with "Russian Federation", then replace it with "Russia
.The second is to use mutate
and
case_when
of tidyverse
.
The third is to use left_join
after making a
comparison table.
df_f3_rev <- df_f3
df_f3_rev$Country[df_f3_rev$Country == "Russian Federation"] <- "Russia"
df_f3_rev$Country[df_f3_rev$Country == "DR Congo"] <- "Democratic Republic of the Congo"
df_f3_rev$Country[df_f3_rev$Country == "Congo"] <- "Republic of Congo"
anti_join
. By
the code below, we can create a new table such that there is no region
in world_map
corresponding to Country in
df_f3_rev
.df_f3_rev %>% anti_join(world_map, by = c("Country" = "region"))
We can proceed one by one. However, WIR provides the code of this
part in R. So let us use it. It is in Computer Codes at the Methodology
site. Download
‘Full Datasets’ and ‘Computer Codes’. Then in WIR2022 - Computer codes,
find Chapter1_Maps.R
.
map<-map_data("world")
map$region[map$region=="Democratic Republic of the Congo"]<-"DR Congo"
map$region[map$region=="Republic of Congo"]<-"Congo"
map$region[map$region=="Ivory Coast"]<-"Cote dIvoire"
map$region[map$region=="Vietnam"]<-"Viet Nam"
# map$region[map$region=="United Arab Emirates"]<-"UAE"
The last one for UAE seems to be wrong, so deleted.
Since the data used in the next line was not find, let me use
map
now.
index_region2<-read_dta("index_region.dta")
map<-left_join(map,index_region2,by=c("region"="name_region"))
map$ISO[map$region=="Greenland"]<-"GL"
map$ISO[map$region=="UAE"]<-"AE"
map$ISO[map$region=="Brunei"]<-"BR" # done
map$ISO[map$region=="Antigua"]<-"AG"
map$ISO[map$region=="Cape Verde"]<-"CV"
map$ISO[map$region=="Cote dIvoire"]<-"CI"
map$ISO[map$region=="UK"]<-"GB" # done
map$ISO[map$region=="Canary Islands"]<-"ES"
map$ISO[map$region=="French Guiana"]<-"FR"
map$ISO[map$region=="Saint Kitts"]<-"KN"
map$ISO[map$region=="South Korea"]<-"KR"
map$ISO[map$region=="Saint Martin"]<-"MF"
map$ISO[map$region=="Macedonia"]<-"MK"
map$ISO[map$region=="Russia"]<-"RU" # done
map$ISO[map$region=="Bonaire"]<-"BQ"
map$ISO[map$region=="Sint Eustatius"]<-"BQ"
map$ISO[map$region=="Saba"]<-"BQ"
map$ISO[map$region=="Laos"]<-"LA"
map$ISO[map$region=="Sint Maarten"]<-"SX"
map$ISO[map$region=="Syria"]<-"SY"
map$ISO[map$region=="Trinidad"]<-"TT"
map$ISO[map$region=="Tobago"]<-"TT"
map$ISO[map$region=="Virgin Islands"]<-"VI"
map$ISO[map$region=="Saint Vincent"]<-"VC"
map$ISO[map$region=="Grenadines"]<-"VC"
map$ISO[map$region=="French Southern and Antarctic Lands"]<-"FR"
map$ISO[map$region=="Western Sahara"]<-"WS"
map$region[map$region=="Russia"]<-"Russian Federation"
map$region[map$region=="South Korea"]<-"Korea"
map$region[map$region=="UK"]<-"United Kingdom"
map$region[map$region=="Brunei"]<-"Brunei Darussalam"
map$region[map$region=="Laos"]<-"Lao PDR"
map$region[map$region=="Cote dIvoire"]<-"Cote d'Ivoire"
map$region[map$region=="Cape Verde"]<- "Cabo Verde"
map$region[map$region=="Syria"]<- "Syrian Arab Republic"
map$region[map$region=="Trinidad"]<- "Trinidad and Tobago"
map$region[map$region=="Tobago"]<- "Trinidad and Tobago"
df_f3 %>% anti_join(map, by = c("Country" = "region"))
df_f3 %>%
ggplot(aes(map_id = Country)) +
geom_map(aes(fill = `T10B50`), map = map) +
expand_limits(x = map$long, y = map$lat)
Top 10 Bottom 50 Ratio
by
setting new breaks of T10B50
.theme(legend.position="bottom")
.df_f3_rev %>%
mutate(`Top 10 Bottom 50 Ratio` = cut(T10B50, breaks = c(5, 12, 13, 16, 19, 140), include.lowest = FALSE)) %>%
ggplot(aes(map_id = Country)) + geom_map(aes(fill = `Top 10 Bottom 50 Ratio`), map = world_map) + expand_limits(x = world_map$long, y = world_map$lat) +
theme(legend.position="bottom")
Finally add the title, remove x and y labels, and change the legend name.
df_f3_rev %>%
mutate(`Top 10 Bottom 50 Ratio` = cut(T10B50, breaks = c(5, 12, 13, 16, 19, 140), include.lowest = FALSE)) %>%
ggplot(aes(map_id = Country)) + geom_map(aes(fill = `Top 10 Bottom 50 Ratio`), map = world_map) + expand_limits(x = world_map$long, y = world_map$lat) +
labs(title = "Figure 3. Top 10/Bottom 50 income gaps across the world, 2021",
x = "", y = "", fill = "Top 10/Bottom 50 ratio") +
theme(legend.position="bottom")
Remove x-axis, y-axis and ticks. If you want to change color palette, see:
df_f3_rev %>%
mutate(`Top 10 Bottom 50 Ratio` = cut(T10B50, breaks = c(5, 12, 13, 16, 19, 140), include.lowest = FALSE)) %>%
ggplot(aes(map_id = Country)) + geom_map(aes(fill = `Top 10 Bottom 50 Ratio`), map = world_map) + expand_limits(x = world_map$long, y = world_map$lat) +
labs(title = "Figure 3. Top 10/Bottom 50 income gaps across the world, 2021",
x = "", y = "", fill = "Top 10/Bottom 50 ratio") +
theme(legend.position="bottom",
axis.text.x=element_blank(), axis.ticks.x=element_blank(),
axis.text.y=element_blank(), axis.ticks.y=element_blank()) +
scale_fill_brewer(palette='YlOrRd')
df_f4 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F4")
df_f4
df_f4 %>% pivot_longer(3:5, names_to = "level", values_to = "value") %>%
ggplot(aes(x = iso, y = value, fill = level)) +
geom_col(position = "dodge") +
scale_x_discrete(labels = function(x) stringr::str_wrap(x, width = 10)) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 4. The extreme concentration of capital: \nwealth inequality across the world, 2021",
x = "", y = "Share of national wealth (%)", fill = "")
Interpretation: The Top 10% in Latin America
captures 77% of total household wealth, versus 22% for the Middle 40%
and 1% for the Bottom 50%. In Europe, the Top 10% owns 58% of total
wealth, versus 38% for the Middle 40% and 4% for the Bottom 50%.
Sources and series: wir2022.wid.world/methodology.
Almost the same as F1 and F2.
Wrap long label:
scale_x_discrete(labels = function(x) stringr::str_wrap(x, width = 10))
Per Cent:
scale_y_continuous(labels = scales::percent_format(accuracy = 1))
df_f5 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F5")
df_f5
df_f5 %>% select(year = y, ratio = t10b50) %>%
ggplot(aes(x = year, y = ratio)) +
lims(y = c(10,70)) +
geom_smooth(formula = y~x, method = "loess", span = 0.25, se = FALSE) +
scale_x_continuous(breaks = round(seq(1820, 2020, by = 20),1)) +
labs(title = "Figure 5. Global income inequality:T10/B50 ratio, 1820-2020",
x = "", y = stringr::str_wrap("Ratio of top 10% average income to bottom 50% average income", width = 35)) +
annotate("text", x = 1840, y = 32, label = stringr::str_wrap("1820: average income of the global top 10% is 18x higher than average income of the bottom 50%", width = 20), size = 3) +
annotate("text", x = 1910, y = 49, label = stringr::str_wrap("1910: average income of the global top 10% is 41x higher than average income of the bottom 50%", width = 20), size = 3) +
annotate("text", x = 1980, y = 60, label = stringr::str_wrap("1980: average income of the global top 10% is 53x higher than average income of the bottom 50%", width = 20), size = 3) +
annotate("text", x = 2010, y = 32, label = stringr::str_wrap("2020: average income of the global top 10% is 38x higher than average income of the bottom 50%", width = 20), size = 3)
Interpretation. Global inequality, as measured by
the ratio T10/B50 between the average income of the top 10% and the
average income of the bottom 50%, more than doubled between between 1820
and 1910, from less than 20 to about 40, and stabilized around 40
between 1910 and 2020. It is too early to say whether the decline in
global inequality observed since 2008 will continue. Income is measured
per capita after pension and unemployement insurance transfers and
before income and wealth taxes.
Sources and series: wir2022.wid.world/lmethodology and
Chancel and Piketty (2021)..
str_wrap
to
the label of the y-axis as it is very long.df_f5 %>% select(year = y, ratio = t10b50) %>%
ggplot(aes(x = year, y = ratio)) +
geom_line() +
labs(title = "Figure 5. Global income inequality:T10/B50 ratio, 1820-2020",
x = "", y = stringr::str_wrap("Ratio of top 10% average income to bottom 50% average income", width = 35))
There are many way of smoothing.
Line Plot and LOESS
se = TRUE
which include the
standard error.formula = y~x
, method = "loess", and
se =
FALSE`.df_f5 %>% select(year = y, ratio = t10b50) %>%
ggplot(aes(x = year, y = ratio)) +
geom_line() +
geom_smooth(formula = y~x, method = "loess", se = FALSE) +
labs(title = "Figure 5. Global income inequality:",
subtitle = "T10/B50 ratio, 1820-2020",
x = "", y = "Ratio of top 10% average income to bottom 50% average income")
GAM Smoothing with 24 Points
df_f5 %>% select(year = y, ratio = t10b50) %>%
ggplot(aes(x = year, y = ratio)) +
stat_smooth(method = "gam", formula = y ~ s(x, k = 24), se = FALSE) +
scale_x_continuous(breaks = round(seq(min(df_f5$y), max(df_f5$y), by = 20),1)) +
labs(title = "Figure 5. Global income inequality:T10/B50 ratio, 1820-2020",
x = "", y = stringr::str_wrap("Ratio of top 10% average income to bottom 50% average income", width = 35))
Polynomial Approximation of Degree 6
df_f5 %>% select(year = y, ratio = t10b50) %>%
ggplot(aes(x = year, y = ratio)) +
geom_point() +
geom_smooth(method = "lm", formula = y ~ poly(x, 6), se = FALSE) +
labs(title = "Figure 5. Global income inequality:",
subtitle = "T10/B50 ratio, 1820-2020",
x = "", y = stringr::str_wrap("Ratio of top 10% average income to bottom 50% average income", width = 35))
In the main chart for F5, we applied
geom_smooth(formula = y~x, method = "loess", span = 0.25, se = FALSE)
as it is easy. You can adjust smoothness by changing the value for
span
.
For the y-axis, following the output provided,
lims(y = c(10,70))
is added and annotation.
For a long text use:
stringr::str_wrap("long text", width = size)
and
annotate
with size = fontsize
.
ggforce::geom_mark_rect
will add annotation in a
box.
df_f5 %>% select(year = y, ratio = t10b50) %>%
ggplot(aes(x = year, y = ratio)) +
lims(y = c(10,70)) +
geom_smooth(formula = y~x, method = "loess", span = 0.25, se = FALSE) +
scale_x_continuous(breaks = round(seq(1820, 2020, by = 20),1)) +
labs(title = "Figure 5. Global income inequality:T10/B50 ratio, 1820-2020",
x = "", y = stringr::str_wrap("Ratio of top 10% average income to bottom 50% average income", width = 35)) +
annotate("text", x = 1840, y = 32, label = stringr::str_wrap("1820: average income of the global top 10% is 18x higher than average income of the bottom 50%", width = 20), size = 3) +
annotate("text", x = 1910, y = 49, label = stringr::str_wrap("1910: average income of the global top 10% is 41x higher than average income of the bottom 50%", width = 20), size = 3) +
annotate("text", x = 1980, y = 60, label = stringr::str_wrap("1980: average income of the global top 10% is 53x higher than average income of the bottom 50%", width = 20), size = 3) +
annotate("text", x = 2010, y = 32, label = stringr::str_wrap("2020: average income of the global top 10% is 38x higher than average income of the bottom 50%", width = 20), size = 3)
df_f6 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F6")
New names:
df_f6
df_f6 %>% select(year = "...1", 2:3) %>%
pivot_longer(cols = 2:3, names_to = "type", values_to = "value") %>%
mutate(types = factor(type, levels = c("Within-country inequality", "Between-country inequality"))) %>%
ggplot(aes(x = year, y = value, fill = types)) +
geom_area() +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
scale_x_continuous(breaks = round(seq(1820, 2020, by = 20),1)) +
scale_fill_manual(values=rev(scales::hue_pal()(2)), labels = function(x) str_wrap(x, width = 15)) +
labs(title = "Figure 6. Global income inequality: \nBetween vs. within country inequality (Theil index), 1820-2020",
x = "", y = "Share of global inequality (% of total Theil index)", fill = "") +
annotate("text", x = 1850, y = 0.28, label = stringr::str_wrap("1820: Between country inequality represents 11% of global inequality", width = 20), size = 3) +
annotate("text", x = 1980, y = 0.70, label = stringr::str_wrap("1980: Between country inequality represents 57% of global inequality", width = 20), size = 3) +
annotate("text", x = 1990, y = 0.30, label = stringr::str_wrap("2020: Between country inequality represents 32% of global inequality", width = 20), size = 3)
theme(legend.position="bottom")
df_f6 %>% select(year = "...1", 2:3) %>%
pivot_longer(cols = 2:3, names_to = "type", values_to = "value") %>%
mutate(types = factor(type, levels = c("Within-country inequality", "Between-country inequality"))) %>%
ggplot(aes(x = year, y = value, fill = types)) +
geom_area() +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
scale_x_continuous(breaks = round(seq(1820, 2020, by = 20),1)) +
scale_fill_manual(values=rev(scales::hue_pal()(2))) +
labs(title = "Figure 6. Global income inequality: \nBetween vs. within country inequality (Theil index), 1820-2020",
x = "", y = "Share of global inequality (% of total Theil index)", fill = "") +
annotate("text", x = 1850, y = 0.28, label = stringr::str_wrap("1820: Between country inequality represents 11% of global inequality", width = 20), size = 3) +
annotate("text", x = 1980, y = 0.70, label = stringr::str_wrap("1980: Between country inequality represents 57% of global inequality", width = 20), size = 3) +
annotate("text", x = 1990, y = 0.30, label = stringr::str_wrap("2020: Between country inequality represents 32% of global inequality", width = 20), size = 3) +
theme(legend.position="bottom")
Interpretation. The importance of between-country
inequality in overall global inequality, as measured by the Theil index,
rose between 1820 and 1980 and strongly declined since then. In 2020,
between-country inequality makes-up about a third of global inequality
between individuals. The rest is due to inequality within countries.
Income is measured per capita after pension and unemployement insurance
transfers and before income and wealth taxes.
Sources and series: wir2022.wid.world/methodology and
Chancel and Piketty (2021).
geom_area
after tidying the data with
pilot_longer
.df_f6 %>% select(year = "...1", 2:3) %>%
pivot_longer(cols = 2:3, names_to = "type", values_to = "value") %>%
ggplot(aes(x = year, y = value, fill = type)) +
geom_area() +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 6. Global income inequality: \nBetween vs. within country inequality (Theil index), 1820-2020",
x = "", y = "Share of global inequality (% of total Theil index)")
scale_fill_manual(values=rev(scales::hue_pal()(2)), labels = function(x) str_wrap(x, width = 15))
The second option is to control the legend to wrap.
Annotation can be omitted if we use RMarkdown to explain the charts clearly.
Add a line break in the y-axis label.
df_f6 %>% select(year = "...1", 2:3) %>%
pivot_longer(cols = 2:3, names_to = "type", values_to = "value") %>%
mutate(types = factor(type, levels = c("Within-country inequality", "Between-country inequality"))) %>%
ggplot(aes(x = year, y = value, fill = types)) +
geom_area() +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
scale_x_continuous(breaks = round(seq(1820, 2020, by = 20),1)) +
scale_fill_manual(values=rev(scales::hue_pal()(2)), labels = function(x) str_wrap(x, width = 15)) +
labs(title = "Figure 6. Global income inequality: \nBetween vs. within country inequality (Theil index), 1820-2020",
x = "", y = "Share of global inequality \n(% of total Theil index)", fill = "")
df_f7 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F7")
df_f7
df_f7 %>% select(year = y, 2:4) %>%
pivot_longer(cols = 2:4, names_to = "type", values_to = "value") %>%
ggplot(aes(x = year, y = value, color = type)) +
geom_smooth(formula = y~x, method = "loess", span = 0.25, se = FALSE) +
scale_x_continuous(breaks = round(seq(1820, 2020, by = 20),1)) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 7. Global income inequality, 1820-2020",
x = "", y = " Share of total world income (%)", color = "") +
annotate("text", x = 1980, y = 0.20, label = stringr::str_wrap("The global bottom 50% income share remains historically low despite growth in the emerging world in the past decades.", width = 30), size = 3)
Interpretation. The share of global income going to top 10% highest incomes at the world level has fluctuated around 50-60% between 1820 and 2020 (50% in 1820, 60% in 1910, 56% in 1980, 61% in 2000, 55% in 2020), while the share going to the bottom 50% lowest incomes has generally been around or below 10% (14% in 1820, 7% in 1910, 5% in 1980, 6% in 2000, 7% in 2020). Global inequality has always been very large. It rose between 1820 and 1910 and shows little long-run trend between 1910 and 2020. Distribution of per capita incomes. Sources and series: see wir2022.wid.world/methodology and Chancel and Piketty (2021).
pivot_longer
to tidy the data.df_f7 %>% select(year = y, 2:4) %>%
pivot_longer(cols = 2:4, names_to = "type", values_to = "value")
*Use geom_smooth
with span
, and change the
scale of x-axis and y-axis.
df_f7 %>% select(year = y, 2:4) %>%
pivot_longer(cols = 2:4, names_to = "type", values_to = "value") %>%
ggplot(aes(x = year, y = value, color = type)) +
geom_smooth(formula = y~x, method = "loess", span = 0.25, se = FALSE) +
scale_x_continuous(breaks = round(seq(1820, 2020, by = 20),1)) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 7. Global income inequality, 1820-2020",
x = "", y = " Share of total world income (%)", color = "")
df_f8 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F8")
df_f8
df_f8 %>% drop_na() %>%
select(year, Germany_public = Germany, Germany_private = 'Germany (private)',
Spain_public = Spain, Spain_private = 'Spain (private)',
France_public = France, France_private = 'France (private)',
UK_public = UK, UK_private = 'UK (private)',
Japan_public = Japan, Japan_private = 'Japan (private)',
Norway_public = Norway, Norway_private = 'Norway (private)',
USA_public = USA, USA_private = 'USA (private)') %>%
pivot_longer(!year, names_to = c("country",".value"), names_sep = "_") %>%
pivot_longer(3:4, names_to = "type", values_to = "value") %>%
ggplot() +
stat_smooth(aes(x = year, y = value, color = country, linetype = type),
formula = y~x, method = "loess",
span = 0.25, se = FALSE, size=0.75) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 8. The rise of private versus the decline of \npublic wealth in rich countries, 1970-2020",
x = "", y = "wealth as % of national income", color = "", type = "")
Interpretation: Public wealth is the sum of all
financial and non-financial assets, net of debts, held by governments.
Public wealth dropped from 60% of national income in 1970 to -106% in
2020 in the UK.
Sources and series: wir2022.wid.world/methodology,
Bauluz et al. (2021) and updates.
df_f8 %>%
select(year, Germany_public = Germany, Germany_private = 'Germany (private)',
Spain_public = Spain, Spain_private = 'Spain (private)',
France_public = France, France_private = 'France (private)',
UK_public = UK, UK_private = 'UK (private)',
Japan_public = Japan, Japan_private = 'Japan (private)',
Norway_public = Norway, Norway_private = 'Norway (private)',
USA_public = USA, USA_private = 'USA (private)')
names_sep = "_"
.df_f8 %>%
select(year, Germany_public = Germany, Germany_private = 'Germany (private)',
Spain_public = Spain, Spain_private = 'Spain (private)',
France_public = France, France_private = 'France (private)',
UK_public = UK, UK_private = 'UK (private)',
Japan_public = Japan, Japan_private = 'Japan (private)',
Norway_public = Norway, Norway_private = 'Norway (private)',
USA_public = USA, USA_private = 'USA (private)') %>%
pivot_longer(!year, names_to = c("country",".value"), names_sep = "_")
pivot_longer
again to form the second
group.df_f8 %>%
select(year, Germany_public = Germany, Germany_private = 'Germany (private)',
Spain_public = Spain, Spain_private = 'Spain (private)',
France_public = France, France_private = 'France (private)',
UK_public = UK, UK_private = 'UK (private)',
Japan_public = Japan, Japan_private = 'Japan (private)',
Norway_public = Norway, Norway_private = 'Norway (private)',
USA_public = USA, USA_private = 'USA (private)') %>%
pivot_longer(!year, names_to = c("country",".value"), names_sep = "_") %>%
pivot_longer(3:4, names_to = "type", values_to = "value")
linetype
.df_f8 %>%
select(year, Germany_public = Germany, Germany_private = 'Germany (private)',
Spain_public = Spain, Spain_private = 'Spain (private)',
France_public = France, France_private = 'France (private)',
UK_public = UK, UK_private = 'UK (private)',
Japan_public = Japan, Japan_private = 'Japan (private)',
Norway_public = Norway, Norway_private = 'Norway (private)',
USA_public = USA, USA_private = 'USA (private)') %>%
pivot_longer(!year, names_to = c("country",".value"), names_sep = "_") %>%
pivot_longer(3:4, names_to = "type", values_to = "value") %>%
ggplot() +
geom_smooth(aes(x = year, y = value, color = country, linetype = type),
formula = y~x, method = "loess", span = 0.25, se = FALSE)
drop_na()
size
, change the y-axis to
percents and add the .title.df_f8 %>% drop_na() %>%
select(year, Germany_public = Germany, Germany_private = 'Germany (private)',
Spain_public = Spain, Spain_private = 'Spain (private)',
France_public = France, France_private = 'France (private)',
UK_public = UK, UK_private = 'UK (private)',
Japan_public = Japan, Japan_private = 'Japan (private)',
Norway_public = Norway, Norway_private = 'Norway (private)',
USA_public = USA, USA_private = 'USA (private)') %>%
pivot_longer(!year, names_to = c("country",".value"), names_sep = "_") %>%
pivot_longer(3:4, names_to = "type", values_to = "value") %>%
ggplot() +
geom_smooth(aes(x = year, y = value, color = country, linetype = type),
formula = y~x, method = "loess",
span = 0.25, se = FALSE, size=0.75) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 8. The rise of private versus the decline of \npublic wealth in rich countries, 1970-2020",
x = "", y = "wealth as % of national income", color = "", type = "")
df_f8 %>% drop_na() %>%
pivot_longer(!year, names_to = "group", values_to = "value") %>%
ggplot() +
geom_smooth(aes(x = year, y = value, color = group),
formula = y~x, method = "loess",
span = 0.25, se = FALSE, size=0.75) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 8. The rise of private versus \nthe decline of public wealth in rich countries, \n1970-2020",
x = "", y = "wealth as % of national income", color = "")
df_f9 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F9")
df_f9
brks <- c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99, 99.9, 99.99, 99.999)
df_f9 %>%
mutate(level = cut(p, breaks = c(brks,100), labels = as.character(brks), include.lowest = TRUE)) %>%
mutate(xlabel = as.numeric(level)+0.8) %>%
ggplot(aes(x = xlabel, y = `Wealth growth 1995-2021`)) + geom_smooth(method = "loess", formula = y~x, se = FALSE, span = 0.5) +
scale_x_discrete(limits=as.character(brks)) +
scale_y_continuous(labels = scales::percent_format(accuracy = 0.1)) +
labs(title = "Figure 9. Average annual wealth growth rate, 1995-2021",
x = "←1% poorest Global wealth group 0.001% richest→",
y = "Per adult annual growth rate in wealth, \nnet of inflation (%)")
Interpretation: Growth rates among the poorest half
of the population were between 3% and 4% per year, between 1995 and
2021. Since this group started from very low wealth levels, its absolute
levels of growth remained very low. The poorest half of the world
population only captured 2.3% of overall wealth growth since 1995. The
top 1% benefited from high growth rates (3% to 9% per year). This group
captured 38% of total wealth growth between 1995 and 2021. Net household
wealth is equal to the sum of financial assets (e.g. equity or bonds)
and non-financial assets (e.g. housing or land) owned by individuals,
net of their debts.
Sources and series: wir2022.wid.world/methodology.
{width = 100%}
df_f9 %>% distinct(p) %>% pull()
[1] 0.000 1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000
[10] 9.000 10.000 11.000 12.000 13.000 14.000 15.000 16.000 17.000
[19] 18.000 19.000 20.000 21.000 22.000 23.000 24.000 25.000 26.000
[28] 27.000 28.000 29.000 30.000 31.000 32.000 33.000 34.000 35.000
[37] 36.000 37.000 38.000 39.000 40.000 41.000 42.000 43.000 44.000
[46] 45.000 46.000 47.000 48.000 49.000 50.000 51.000 52.000 53.000
[55] 54.000 55.000 56.000 57.000 58.000 59.000 60.000 61.000 62.000
[64] 63.000 64.000 65.000 66.000 67.000 68.000 69.000 70.000 71.000
[73] 72.000 73.000 74.000 75.000 76.000 77.000 78.000 79.000 80.000
[82] 81.000 82.000 83.000 84.000 85.000 86.000 87.000 88.000 89.000
[91] 90.000 91.000 92.000 93.000 94.000 95.000 96.000 97.000 98.000
[100] 99.000 99.900 99.990 99.999
brks <- c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 99, 99.9, 99.99, 99.999)
df_f9 %>% mutate(level = cut(p, breaks = c(brks,100), labels = as.character(brks), include.lowest = TRUE))
xlabel
in numeric.df_f9 %>% mutate(level = cut(p, breaks = c(brks,100), labels = as.character(brks), include.lowest = TRUE)) %>%
mutate(xlabel = as.numeric(level))
geom_smooth
.df_f9 %>% mutate(level = cut(p, breaks = c(brks,100), labels = as.character(brks), include.lowest = TRUE)) %>%
mutate(xlabel = as.numeric(level)+0.5) %>%
ggplot(aes(x = xlabel, y = `Wealth growth 1995-2021`)) + geom_smooth(method = "loess", formula = y~x, se = FALSE, span = 0.5)
scale_x_discrete(limits=as.character(brks))
to
change the label of the x-axis.scale_y_continuous(labels = scales::percent_format(accuracy = 0.1))
.df_f9 %>% mutate(level = cut(p, breaks = c(brks,100), labels = as.character(brks), include.lowest = TRUE)) %>%
mutate(xlabel = as.numeric(level)+ 0.8) %>%
ggplot(aes(x = xlabel, y = `Wealth growth 1995-2021`)) + geom_smooth(method = "loess", formula = y~x, se = FALSE, span = 0.5) +
scale_x_discrete(limits=as.character(brks)) +
scale_y_continuous(labels = scales::percent_format(accuracy = 0.1))
Note that the sheet name of F14 has period at the end. Note that
summary_sheets[31] =
data-F14. with a period.
df_f14 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F14.")
df_f14
\n
for line break in the title.df_f14 %>%
ggplot(aes(x = Group, y = Share)) +
geom_col(width = 0.5, fill = scales::hue_pal()(1)[1]) +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
labs(title = "Figure 14. Global carbon inequality, \n2019 Group contribution to world emissions (%)",
x = "", y = "Share of world emissions (%)")
Interpretation: Personal carbon footprints include emissions from domestic consumption, public and private investments as well as imports and exports of carbon embedded in goods and services traded with the rest of the world. Modeled estimates based on the systematic combination of tax data, household surveys and input-output tables. Emissions split equally within households. Sources and series: wir2022.wid.world/methodology and Chancel (2021).
Not so difficult. You can assign color name. See http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/.
df_f15 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx", sheet = "data-F15")
df_f15
df_f15 %>% mutate(region = rep(regionWID[!is.na(regionWID)], each = 3)) %>%
select(region, group, tcap) %>%
ggplot(aes(x = region, y = tcap, fill = group)) +
geom_col(position = "dodge") +
scale_x_discrete(labels = function(x) stringr::str_wrap(x, width = 10)) +
labs(title = "Figure 15 Per capita emissions across the world, 2019",
x = "", y = "tonnes of CO2e per person per year", fill = "")
Interpretation: Personal carbon footprints include emissions from domestic consumption, public and private investments as well as imports and exports of carbon embedded in goods and services traded with the rest of the world. Modeled estimates based on the systematic combination of tax data, household surveys and input-output tables. Emissions split equally within households. Sources and series: wir2022.wid.world/methodology and Chancel (2021).
It is in Excel stype and there are missing values in the first column. In order to add a new column, let us check the following.
region_test <- rep(df_f15$regionWID[!is.na(df_f15$regionWID)], each = 3)
region_test
[1] "East Asia" "East Asia"
[3] "East Asia" "Europe"
[5] "Europe" "Europe"
[7] "North America" "North America"
[9] "North America" "South & South-East Asia"
[11] "South & South-East Asia" "South & South-East Asia"
[13] "Russia & Central Asia" "Russia & Central Asia"
[15] "Russia & Central Asia" "MENA"
[17] "MENA" "MENA"
[19] "Latin America" "Latin America"
[21] "Latin America" "Sub-Saharan Africa"
[23] "Sub-Saharan Africa" "Sub-Saharan Africa"
Add the names of the region in the last column by mutate
and choose columns by select
.
df_f15 %>% mutate(region = rep(regionWID[!is.na(regionWID)], each = 3))
df_f15 %>% mutate(region = rep(regionWID[!is.na(regionWID)], each = 3)) %>%
select(region, group, tcap)
Now it is not difficult to draw a chart.
df_f15 %>% mutate(region = rep(regionWID[!is.na(regionWID)], each = 3)) %>%
select(region, group, tcap) %>%
ggplot(aes(x = region, y = tcap, fill = group)) +
geom_col(position = "dodge") +
scale_x_discrete(labels = function(x) stringr::str_wrap(x, width = 10)) +
labs(title = "Figure 15 Per capita emissions across the world, 2019",
x = "", y = "tonnes of CO2e per person per year", fill = "")
Check the format of the sheet and add
skip=4, n_max=7
.
df_t1 <- read_excel("./data/WIR2022TablesFigures-Summary.xlsx",
sheet = "T1", skip = 4, n_max = 7)
df_t1
Interpretation: In 2021, there were 62.2 million people in the world owning more than $1 million (measured at Market Exchange Rates). Their average wealth was $ 2.8 million, representing a total of $174 trillion. In our Tax scenario 2, a global progressive wealth tax would yield 2.1% of global income, taking into account capital depreciation and evasion. Sources and series: wir2022.wid.world/methodology.
There are three ways to import data used in Chapter 1 to Chapter 10.
Go to the Methodology site: https://wir2022.wid.world/methodology/
Copy the link to Dataset 2, i.e., the datasets of chapters 1 to 10.
url_wir1to10 <- "https://wir2022.wid.world/www-site/uploads/2022/03/WIR2022TablesFigures-Chapter.zip"
download.file(url_wir1to10, destfile = "./data/wir1to10.zip", mode = "wb")
unzip("./data/wir1to10.zip", exdir = "./data")
list.files("./data/WIR2022TablesFigures-Chapter")
excel_sheets("./data/WIR2022TablesFigures-Chapter/WIR2022TablesFigures-Chapter1.xlsx")
wir_F1.0 <- read_excel("./data/WIR2022TablesFigures-Chapter/WIR2022TablesFigures-Chapter1.xlsx", sheet = "data-F1.0")
wir_F1.0
wir_F1.0 <- wir_F1.0 %>% slice(1:2)
wir_F1.0
wir_F1.0a <- read_excel("./data/WIR2022TablesFigures-Chapter/WIR2022TablesFigures-Chapter1.xlsx", sheet = "data-F1.0", range = "A2:E4")
wir_F1.0a
wir_F1.0b <- read_excel("./data/WIR2022TablesFigures-Chapter/WIR2022TablesFigures-Chapter1.xlsx", sheet = "data-F1.0", range = "A7:E9")
wir_F1.0b
Go to the Methodology site: https://wir2022.wid.world/methodology/
Double click the download link under Dataset 2, i.e., the datasets of chapters 1 to 10 to dounload the zip file.
Unzip the file using the helper application of your PC. In most cases, if you double click the zip file, you can get a folder containing Excel files.
Move to your data folder and follow the line above of the previous method.
Since the table structure of Excel is complicated, it may be much easier to copy and paste the range you want to use. In this case keep the record of the data so that the method is reproducible.
# Copy the range of an Excel sheet into your clipboard
wir_F1.0c <- read_delim(clipboard())
wid
to Download DataIn the following, we explain how to download data by an R package
wid-r-tool
. First, you need to install the package. The
wid-r-tool
is a package in the development stage; it is not
an official R package yet; you need to use the package
devtools
to install it.
To install, run the following code or in Console. If you are recommended to update, select one by choosing ‘All’.
install.packages("devtools")
devtools::install_github("WIDworld/wid-r-tool")
For references use ‘?download_wid’ or put ‘download_wid’ in the search box under Help.
It is similar to WDI
. For more detail and examples, see
vignettes.
For indicators of WIR, see codebook.
library("wid")
This example is essentially the same as in the vignettes.
# Average national income data
data <- download_wid(
indicators = "anninc", # Average net national income
areas = c("JP", "FR", "US", "DE", "GB"),
ages = 992 # Adults
) %>% rename(value_lcu = value)
# Purchasing power parities with US dollar
ppp <- download_wid(
indicators = "xlcusp", # US PPP
areas = c("JP", "FR", "US", "DE", "GB"), # France, China and United States
year = 2016 # Reference year only
) %>% rename(ppp = value) %>% select(-year, -percentile)
# Convert from local currency to PPP US dollar
data <- merge(data, ppp, by = "country") %>%
mutate(value_ppp = value_lcu/ppp) %>%
filter(year %in% 1950:2021)
ggplot(data) +
geom_line(aes(x = year, y = value_ppp, color = country, linetype=country)) +
scale_y_log10(breaks = c(2e3, 5e3, 1e4, 2e4, 5e4)) +
ylab("2016 $ PPP") +
scale_color_discrete(
labels = c("JP" = "Japan", "US" = "USA", "FR" = "France", "DE" = "Germany", "GB" = "UK")
) +
scale_linetype_discrete(
labels = c("JP" = "Japan", "US" = "USA", "FR" = "France", "DE" = "Germany", "GB" = "UK")
) +
ggtitle("Average net national income per adult")
wealg
and wealp
We use the folowing two indicators.
download_wid
.library(wid)
wwealg <- download_wid(indicators = "wwealg", areas = "all", years = "all")
wwealp <- download_wid(indicators = "wwealp", areas = "all", years = "all")
public <- wwealg %>% select(country, year, public = value)
public
private <- wwealp %>% select(country, year, private = value)
private
*Combine two tables.
public_vs_private <- public %>% left_join(private)
Joining, by = c("country", "year")
public_vs_private
To add country names, use the WDI data.
We use a package WDI
to use WDIcache()
as a reference.
wdi_cache <- WDI::WDIcache()
left_join
to add country namesdf_pub_priv <- public_vs_private %>% pivot_longer(cols = c(3,4), names_to = "category", values_to = "value") %>% left_join(wdi_cache$country, by = c("country"="iso2c")) %>%
select(country = country.y, iso2c = country, year, category, value, region, income, lending)
df_pub_priv
df_pub_priv %>% filter(is.na(country)) %>%
filter(nchar(iso2c)==2) %>%
distinct(iso2c) %>% pull(iso2c)
[1] "AI" "MS" "OA" "OB" "OC" "OD" "OH" "OI" "OJ" "QB" "QC" "QD" "QE"
[14] "QF" "QG" "QH" "QI" "QJ" "QK" "QL" "QM" "QN" "QO" "QP" "QQ" "QR"
[27] "QS" "QT" "QU" "QV" "QW" "QX" "QY" "WO" "XA" "XB" "XR" "XS"
unique(df_pub_priv$country)
[1] "Andorra"
[2] "United Arab Emirates"
[3] "Afghanistan"
[4] "Antigua and Barbuda"
[5] NA
[6] "Albania"
[7] "Armenia"
[8] "Angola"
[9] "Argentina"
[10] "American Samoa"
[11] "Austria"
[12] "Australia"
[13] "Aruba"
[14] "Azerbaijan"
[15] "Bosnia and Herzegovina"
[16] "Barbados"
[17] "Bangladesh"
[18] "Belgium"
[19] "Burkina Faso"
[20] "Bulgaria"
[21] "Bahrain"
[22] "Burundi"
[23] "Benin"
[24] "Bermuda"
[25] "Brunei Darussalam"
[26] "Bolivia"
[27] "Brazil"
[28] "Bahamas, The"
[29] "Bhutan"
[30] "Botswana"
[31] "Belize"
[32] "Canada"
[33] "Congo, Dem. Rep."
[34] "Central African Republic"
[35] "Congo, Rep."
[36] "Switzerland"
[37] "Cote d'Ivoire"
[38] "Chile"
[39] "Cameroon"
[40] "China"
[41] "Colombia"
[42] "Costa Rica"
[43] "Cuba"
[44] "Cabo Verde"
[45] "Curacao"
[46] "Cyprus"
[47] "Czechia"
[48] "Germany"
[49] "Djibouti"
[50] "Denmark"
[51] "Dominica"
[52] "Dominican Republic"
[53] "Algeria"
[54] "Ecuador"
[55] "Estonia"
[56] "Egypt, Arab Rep."
[57] "Eritrea"
[58] "Spain"
[59] "Ethiopia"
[60] "Finland"
[61] "Fiji"
[62] "Micronesia, Fed. Sts."
[63] "France"
[64] "Gabon"
[65] "United Kingdom"
[66] "Grenada"
[67] "Georgia"
[68] "Ghana"
[69] "Greenland"
[70] "Gambia, The"
[71] "Guinea"
[72] "Equatorial Guinea"
[73] "Greece"
[74] "Guatemala"
[75] "Guam"
[76] "Guinea-Bissau"
[77] "Guyana"
[78] "Hong Kong SAR, China"
[79] "Honduras"
[80] "Croatia"
[81] "Haiti"
[82] "Hungary"
[83] "Indonesia"
[84] "Ireland"
[85] "Israel"
[86] "Isle of Man"
[87] "India"
[88] "Iraq"
[89] "Iran, Islamic Rep."
[90] "Iceland"
[91] "Italy"
[92] "Jamaica"
[93] "Jordan"
[94] "Japan"
[95] "Kenya"
[96] "Kyrgyz Republic"
[97] "Cambodia"
[98] "Kiribati"
[99] "Comoros"
[100] "St. Kitts and Nevis"
[101] "Korea, Dem. People's Rep."
[102] "Korea, Rep."
[103] "Kuwait"
[104] "Cayman Islands"
[105] "Kazakhstan"
[106] "Lao PDR"
[107] "Lebanon"
[108] "St. Lucia"
[109] "Liechtenstein"
[110] "Sri Lanka"
[111] "Liberia"
[112] "Lesotho"
[113] "Lithuania"
[114] "Luxembourg"
[115] "Latvia"
[116] "Libya"
[117] "Morocco"
[118] "Monaco"
[119] "Moldova"
[120] "Montenegro"
[121] "Madagascar"
[122] "Marshall Islands"
[123] "North Macedonia"
[124] "Mali"
[125] "Myanmar"
[126] "Mongolia"
[127] "Macao SAR, China"
[128] "Northern Mariana Islands"
[129] "Mauritania"
[130] "Malta"
[131] "Mauritius"
[132] "Maldives"
[133] "Malawi"
[134] "Mexico"
[135] "Malaysia"
[136] "Mozambique"
[137] "Namibia"
[138] "New Caledonia"
[139] "Niger"
[140] "Nigeria"
[141] "Nicaragua"
[142] "Netherlands"
[143] "Norway"
[144] "Nepal"
[145] "Nauru"
[146] "New Zealand"
[147] "OECD members"
[148] "Oman"
[149] "Panama"
[150] "Peru"
[151] "French Polynesia"
[152] "Papua New Guinea"
[153] "Philippines"
[154] "Pakistan"
[155] "Poland"
[156] "Puerto Rico"
[157] "West Bank and Gaza"
[158] "Portugal"
[159] "Palau"
[160] "Paraguay"
[161] "Qatar"
[162] "Romania"
[163] "Serbia"
[164] "Russian Federation"
[165] "Rwanda"
[166] "Saudi Arabia"
[167] "Solomon Islands"
[168] "Seychelles"
[169] "Sudan"
[170] "Sweden"
[171] "Singapore"
[172] "Slovenia"
[173] "Slovak Republic"
[174] "Sierra Leone"
[175] "San Marino"
[176] "Senegal"
[177] "Somalia"
[178] "Suriname"
[179] "South Sudan"
[180] "Sao Tome and Principe"
[181] "El Salvador"
[182] "Sint Maarten (Dutch part)"
[183] "Syrian Arab Republic"
[184] "Eswatini"
[185] "Turks and Caicos Islands"
[186] "Chad"
[187] "Togo"
[188] "Thailand"
[189] "Tajikistan"
[190] "Timor-Leste"
[191] "Turkmenistan"
[192] "Tunisia"
[193] "Tonga"
[194] "Turkiye"
[195] "Trinidad and Tobago"
[196] "Tuvalu"
[197] "Taiwan, China"
[198] "Tanzania"
[199] "Ukraine"
[200] "Uganda"
[201] "United States"
[202] "Uruguay"
[203] "Uzbekistan"
[204] "St. Vincent and the Grenadines"
[205] "Venezuela, RB"
[206] "British Virgin Islands"
[207] "Virgin Islands (U.S.)"
[208] "Vietnam"
[209] "Vanuatu"
[210] "Samoa"
[211] "IBRD only"
[212] "IDA only"
[213] "Least developed countries: UN classification"
[214] "Low income"
[215] "Lower middle income"
[216] "Yemen, Rep."
[217] "South Africa"
[218] "Zambia"
[219] "Zimbabwe"
Draw a chart.
df_pub_priv %>%
filter(country %in% c("Japan", "Norway", "Sweden", "Denmark", "Finland"), year %in% 1970:2020) %>%
ggplot(aes(year, value, color = country, linetype = category)) + geom_line()
We choose two indicators: ‘wealg’ and ‘wealp’. WIR2022 indicators consists of 6 characters; 1 letter code plus 5 letter code. You can find the list in the codebook.
If you want to study WIR2022, please study the report, the codebook, and wir vignette together with the R Notebook.