-
Notifications
You must be signed in to change notification settings - Fork 0
/
tl2-chl.qmd
789 lines (673 loc) · 23.2 KB
/
tl2-chl.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
```{r chl_ctry}
ctry <- "CHL"
ctry2 <- "Chile"
```
# Chile
```{r chl_pkgs, warning=FALSE}
library(oecdcountryprofiles)
library(dplyr)
library(tidyr)
library(ggplot2)
library(patchwork)
library(oecdplot)
library(knitr)
library(readxl)
library(janitor)
library(stringr)
library(readr)
library(tintin)
library(glue)
library(scales)
library(plotly)
load_oecd_fonts()
missing_reg <- c("ITG2F")
excl_countries <- c("LUX", "IRL")
clrs <- tintin_colours$the_black_island
clrs2 <- tintin_colours$the_blue_lotus
clrs3 <- tintin_colours$the_red_sea_sharks
clrs4 <- tintin_colours$the_calculus_affair
clrs5 <- tintin_colours$red_rackhams_treasure
```
<table border="1" style="width:75%;margin-left:auto;margin-right:auto;">
<tr>
<th colspan="2" style="background:#fff9e6; padding:10px;font-size:9.0pt;" valign="center">
OECD Regional Outlook
</th>
</tr>
<tr>
<td>
<img style="padding:10px;" src="RO2023_cover.jpg" alt="OECD Regional Outlook 2023" height="200"/>
</td>
<td>
<p style="padding:10px;font-size:9.0pt;">The OECD <a href="https://www.oecd-ilibrary.org/urban-rural-and-regional-development/oecd-regional-outlook_2dafc8cf-en" target="_blank"><i style="color:#0d6efd">Regional Outlook</i></a> reviews recent trends, policy developments, and prospects across OECD regions, including the underlying causes driving regional inequalities in performance and well-being. The report offers evidence, guidance and policy recommendations on how to improve competitiveness and productivity, promote inclusive growth, accelerate the net-zero transition and raise well-being standards through effective regional development policy and multi-level governance.</p>
</td>
</tr>
</table>
## Overview
```{r chl_tbl}
read_html_table(ctry)
```
## Regional inequality trends
```{r chl_fig1}
iso3_g20 <- read_csv("data/ISO_3_G20.csv") %>%
clean_names() %>%
rename(iso3 = iso_3)
top_bottom_c <- read_excel("data/top_bottom_gdppc_w_agg.xlsx") %>%
filter(TIME < 2021) %>%
clean_names()
gdp_pop_00_20 <- read_csv("data/gdp_pop_00_20_imputed_agg_l.csv") %>%
filter(TIME < 2021) %>%
clean_names() %>%
select(-x1) %>%
left_join(iso3_g20, by = "iso3") %>%
filter(!reg_id %in% missing_reg, !iso3 %in% excl_countries) %>%
mutate(
metro_large = ifelse(metro_large != "Metropolitan large", "Non-large", metro_large),
metro_far = ifelse(metro_far != "Far from a FUA>250K", "Close", metro_far)
) %>%
bind_rows(
read_csv("data/gdp_pop_tl2_00_20_imputed_l_CHL_PACHA.csv") %>%
filter(time < 2021) %>%
clean_names() %>%
select(time, reg_id, iso3, gdp, pop, gdp_pc, regional_name_eng = reg_name)
)
summary_theil_tl2 <- read_csv("data/theil_gdppc_country_00_20_wCHE-CHL.csv") %>%
filter(TIME < 2021) %>%
clean_names() %>%
filter(level == "gdppc_tl2") %>%
select(-c(x1, level))
# summary_theil_tl2 %>%
# filter(iso3 == ctry)
summary_stats <- gdp_pop_00_20 %>%
group_by(iso3, time) %>%
summarise(mean_gdp_pc = mean(gdp_pc, na.rm = TRUE)) %>%
ungroup() %>%
left_join(top_bottom_c, by = c("iso3", "time")) %>%
mutate(
top_bottom = top_20_gdppc / bottom_20_gdppc,
top_mean = top_20_gdppc / mean_gdp_pc,
bottom_mean = bottom_20_gdppc / mean_gdp_pc
)
# no gdp data for CHL
# summary_stats %>%
# filter(iso3 == ctry)
summary_stats <- summary_stats %>%
full_join(summary_theil_tl2, by = c("iso3", "time"))
# summary_stats %>%
# filter(iso3 == ctry) %>%
# select(time, theil)
min_y <- summary_theil_tl2 %>%
filter(iso3 == ctry) %>%
pull(time) %>%
min()
index_200x <- summary_stats %>%
filter(time == min_y) %>%
pivot_wider(
id_cols = "iso3",
names_from = "time",
values_from = -c(time, iso3)
)
# index_200x %>%
# filter(iso3 == ctry) %>%
# select(theil_2008)
# => rename cols
colnames(index_200x) <- gsub("_200[0-9]", "_200x", colnames(index_200x))
summary_stats_index <- summary_stats %>%
full_join(index_200x, by = "iso3") %>%
mutate(
index_gdppc = mean_gdp_pc / mean_gdp_pc_200x,
index_bottom = bottom_mean / bottom_mean_200x,
index_top = top_mean / top_mean_200x,
index_theil = theil / theil_200x,
index_top_mean = top_mean / top_mean_200x,
index_bottom_mean = bottom_mean / bottom_mean_200x,
index_top_bottom = top_bottom / top_bottom_200x
) %>%
select(
iso3,
time,
index_gdppc,
index_bottom,
index_top_mean,
index_top_bottom,
index_bottom_mean,
index_top,
index_theil
)
summary_wide <- summary_stats_index %>%
pivot_longer(cols = -c(time, iso3), names_to = "index") %>%
mutate(
labels_index = case_when(
index == "index_bottom" ~ "Bottom 20%",
index == "index_top" ~ "Top 20%",
index == "index_bottom_mean" ~ "Bottom 20%/Mean",
index == "index_top_mean" ~ "Top 20%/Mean",
index == "index_theil" ~ "Theil index",
index == "index_gdppc" ~ "Mean GDP per capita",
index == "index_top_bottom" ~ "Top 20%/Bottom 20%"
)
) %>%
left_join(iso3_g20, by = "iso3")
lev_2 <- c(
"Theil index",
"Mean GDP per capita"
)
max_x <- max(summary_wide$time)
min_x <- min(summary_wide$time)
fig1 <- summary_wide %>%
filter(iso3 == ctry, labels_index %in% lev_2) %>%
pivot_wider(
names_from = index,
values_from = value
) %>%
mutate(
index_label = factor(labels_index, levels = lev_2)
) %>%
ggplot(aes(x = time)) +
geom_line(aes(
y = index_gdppc,
colour = index_label
), linetype = "dashed", linewidth = 1.2) +
geom_line(aes(
y = index_theil,
colour = index_label
), linewidth = 1.2) +
scale_colour_manual(values = clrs2) +
scale_x_continuous(
expand = c(0, 0),
n.breaks = round((max_x - min_x) / 2, 0)
) +
labs(
title = "Figure 1: Trends in GDP per capita inequality indicators,\nTL2 OECD regions",
x = "",
y = sprintf("Statistic (%s=1)", min_y),
linetype = "",
colour = ""
) +
# theme_oecd(base_size = 10) +
# theme(plot.title = element_text(size = 13, hjust = 0, margin = margin(0, 0, 10, 0)))
theme_minimal()
```
```{r chl_fig1_summary}
# range(summary_wide$time) # = 2000-2021!!!
theil_chg <- summary_wide %>%
# filter in 2 steps to avoid an out of range year
filter(
index == "index_theil",
iso3 == ctry
) %>%
filter(
time %in% range(time)
) %>%
arrange(time) %>%
mutate(diff = value - lag(value)) %>%
filter(time == max(time)) %>%
pull(diff)
theil_chg_txt <- ifelse(theil_chg > 0, "an increase", "a decline")
theil_max <- summary_wide %>%
filter(
index == "index_theil",
iso3 == ctry
) %>%
filter(value == max(value)) %>%
pull(time) %>%
as.integer()
polarization_pct <- summary_wide %>%
filter(
index == "index_top_mean",
iso3 == ctry
) %>%
filter(time %in% range(time)) %>%
arrange(time) %>%
mutate(diff = lead(value) - value) %>%
filter(time == min(time)) %>%
pull(diff) %>%
round(3)
polarization_txt <- ifelse(polarization_pct > 0, "higher", "lower")
polarization_txt2 <- ifelse(polarization_txt == "higher", "increased", "decreased")
polarization_yrs <- summary_wide %>%
filter(
index == "index_top_mean",
iso3 == ctry
) %>%
filter(time %in% range(time)) %>%
pull(time) %>%
as.integer()
polarization_2_pct <- summary_wide %>%
filter(
index == "index_bottom_mean",
iso3 == ctry
) %>%
filter(
time %in% range(time)
) %>%
arrange(time) %>%
mutate(diff = lead(value) - value) %>%
filter(time == min(time)) %>%
pull(diff) %>%
round(3)
polarization_2_txt <- ifelse(polarization_2_pct > 0, "higher", "lower")
polarization_2_txt2 <- ifelse(polarization_2_txt == "higher", "convergence", "divergence")
polarization_yrs_txt <- summary_wide %>%
filter(
index == "index_bottom_mean",
iso3 == ctry
) %>%
filter(
time %in% range(time)
) %>%
arrange(time) %>%
pull(time) %>%
as.character()
# not all countries have polarization data
theil_paragraph <- glue("{ctry2} experienced {theil_chg_txt} in the Theil index of GDP per capita over {polarization_yrs_txt[1]}-{polarization_yrs_txt[2]}. Inequality reached its maximum in {theil_max}. The figures are normalized, with values in the year {as.integer(min_y)} set to 1.")
theil_paragraph_2 <- if (is.na(polarization_2_pct)) {
""
} else {
glue("Polarisation, as measured by the Top 20%/Mean ratio was { paste(abs(polarization_pct), polarization_txt) } in { max(polarization_yrs) } compared to { min(polarization_yrs) }, indicating { polarization_txt2 } polarisation. Bottom divergence, as measured by the Bottom 20%/Mean ratio was { paste(abs(polarization_2_pct), polarization_2_txt) } in the same period, indicating bottom { polarization_2_txt2 }.")
}
```
`r theil_paragraph`
`r theil_paragraph_2`
```{r chl_fig1_1}
# no interactivity
# fig1
# interactivity
ggplotly(fig1) %>%
config(displayModeBar = F)
```
<div class="oecdnote">
**Source**: OECD Regional Database (2022).
</div>
<br>
<br>
```{r chl_fig2}
# read ----
#
# finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
# "data/countryprofile_option1_addon.xlsx"
# } else {
# "data/countryprofile_option1.xlsx"
# }
#
# dp1 <- read_excel(finp, sheet = ctry) %>%
# clean_names()
#
# # tidy ----
#
# colnames(dp1) <- str_replace(colnames(dp1), tolower(ctry), "country")
dp1 <- read_excel("data/countryprofile_fig3_alt.xlsx", sheet = ctry) %>%
select(time, pw_lp, pw_hp) %>%
clean_names()
colnames(dp1) <- c("time", "pw_lp_country", "pw_hp_country")
dp11 <- dp1 %>%
select(time, matches("country")) %>%
pivot_longer(-time) %>%
rename(value_country = value)
dp11 <- dp11 %>%
mutate(
name = case_when(
name == "pw_lp_country" ~ "Lower half",
name == "pw_hp_country" ~ "Upper half"
)
)
# plot ----
yrs <- sort(unique(dp11$time))
yrs <- seq(min(yrs), max(yrs), 2)
hpgrew <- dp11 %>%
filter(
name == "Upper half",
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = 100 * (value_country - lag(value_country)) / lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
lpgrew <- dp11 %>%
filter(
name == "Lower half",
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = 100 * (value_country - lag(value_country)) / lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
hpdiff <- hpgrew - lpgrew
hpmore <- ifelse(hpdiff > 0, "more", "less")
# fig2 <- dp11 %>%
# rename(
# value = value_country,
# series = name
# ) %>%
# ggplot() +
# geom_line(aes(x = time, y = value, color = series), linewidth = 1.2) +
# # theme_oecd(base_size = 10) +
# theme_minimal() +
# scale_colour_manual(values = c("#177dc7","#508551")) +
# labs(
# x = "", y = "Labour productivity (2015 USD PPP)", colour = "",
# title = "Figure 2: Evolution of labour productivity, TL2 regions"
# ) +
# scale_x_continuous(labels = as.character(yrs), breaks = yrs) +
# scale_y_continuous(labels = scales::number_format())+
# theme(title = element_text(family = "serif")) # windowsFonts()
fig3_title <- if (any(ctry %in% c("USA", "TUR", "NOR", "CHE", "CHL"))) {
"Figure 2: Evolution of labour productivity,\nTL2 regions"
} else {
"Figure 2: Evolution of labour productivity,\nTL2 regions"
}
fig2 <- dp11 %>%
rename(
value = value_country,
series = name
) %>%
ggplot() +
geom_line(aes(x = time, y = value, color = series), linewidth = 1.2) +
# theme_oecd(base_size = 10) +
# theme(plot.title = element_text(size = 13, hjust = 0, margin = margin(0, 0, 10, 0))) +
theme_minimal() +
# scale_colour_manual(values = clrs3[1:2]) +
scale_colour_manual(values = c("#508551", "#177dc7")) +
labs(
x = "", y = "Labour productivity (2015 USD PPP)", colour = "",
title = fig3_title
) +
scale_x_continuous(labels = as.character(yrs), breaks = yrs) +
scale_y_continuous(labels = scales::number_format())
ctry3 <- if (any(ctry %in% c("USA", "GBR", "CZE", "SVK", "NLD"))) {
paste("The", ctry2)
} else {
ctry2
}
ctry4 <- if (any(ctry %in% c("USA", "GBR", "CZE", "SVK", "NLD"))) {
paste("the", ctry2)
} else {
ctry2
}
```
```{r aut_fig3_text}
fig3_text <- read_excel("data/fig3_text_FINAL.xlsx", sheet = "text") %>%
clean_names()
fig3_text <- fig3_text %>%
filter(iso3 == ctry) %>%
pull(text_final)
```
`r fig3_text`
```{r chl_fig2_2}
# no interactivity
# fig2
# interactivity
ggplotly(fig2) %>%
config(displayModeBar = F)
```
<div class="oecdnote">
**Note**: A region is in the “upper half” if labour productivity was above the country median in the first year with available data and “lower half” if productivity was below the country median. Labour productivity in each group is equal to the sum of Gross Value Added, expressed in USD at constant prices and PPP (base year 2015) within the group, divided by the sum of total employment in regions within the group. Regions are small (TL3) regions, except for Australia, Canada, Chile, Colombia, Ireland, Mexico, Norway, Switzerland, Türkiye and the United States where they are large (TL2) regions due to data availability.<br>
**Source**: OECD Regional Database (2022).
</div>
<br>
<br>
```{r fig4}
# read ----
dp2 <- read_excel("data/countryprofile_fig4_alt.xlsx", sheet = ctry) %>%
clean_names()
# tidy ----
dp21 <- dp2 %>%
select(time, starts_with("share_")) %>%
pivot_longer(-time) %>%
rename(value_country = value)
dp21 <- dp21 %>%
mutate(
name = case_when(
name == "share_tgoods_lp" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp" ~ paste(ctry, "TS HP")
)
)
# plot ----
yrs <- sort(unique(dp21$time))
yrs <- seq(min(yrs), max(yrs), 1)
tghpgrew <- dp21 %>%
filter(
name == paste(ctry, "TG HP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tglpgrew <- dp21 %>%
filter(
name == paste(ctry, "TG LP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tghpdiff <- tghpgrew - tglpgrew
tghpmore <- ifelse(tghpdiff > 0, "grew", "declined")
tglpdiff <- tglpgrew - tglpgrew
tglpmore <- ifelse(tglpdiff > 0, "grew", "declined")
tshpgrew <- dp21 %>%
filter(
name == paste(ctry, "TS HP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tslpgrew <- dp21 %>%
filter(
name == paste(ctry, "TS LP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tshpdiff <- tshpgrew - tslpgrew
tshpmore <- ifelse(tshpdiff > 0, "grew", "declined")
tslpdiff <- tslpgrew - tslpgrew
tslpmore <- ifelse(tslpdiff > 0, "grew", "declined")
dp21 <- dp21 %>%
mutate(category = gsub(paste0("^OECD |^", ctry, " "), "", name))
dp21 <- dp21 %>%
mutate(
country = str_replace_all(name, " .*", ""),
category1 = str_sub(category, 1, 2),
category1 = str_replace_all(category1, "TG", "Tradable goods"),
category1 = str_replace_all(category1, "TS", "Tradable services"),
category2 = paste(str_sub(category, 4, 5), time),
category2 = str_replace_all(category2, "LP", "Lower half"),
category2 = str_replace_all(category2, "HP", "Upper half")
)
dp21_2 <- dp21 %>%
select(country, time, category1, category2, value_country) %>%
mutate(
category2_2 = category2,
category2 = str_replace_all(category2, as.character(min(yrs)), "minyr"),
category2 = str_replace_all(category2, as.character(max(yrs)), "maxyr")
) %>%
pivot_wider(names_from = category2, values_from = value_country) %>%
clean_names()
# for plot_ly -----
dp21_2 <- dp21 %>%
select(country, time, category1, category2, value_country) %>%
mutate(type = ifelse(str_detect(category2, "Lower"), "Lower half", "Upper half"))
dp21_min_TG <- dp21 %>%
select(country, time, category1, category2, value_country) %>%
mutate(type = ifelse(str_detect(category2, "Lower"), "Lower half", "Upper half")) %>%
filter(time == min(dp21_2$time) & category1 == "Tradable goods")
dp21_min_TS <- dp21 %>%
select(country, time, category1, category2, value_country) %>%
mutate(type = ifelse(str_detect(category2, "Lower"), "Lower half", "Upper half")) %>%
filter(time == min(dp21_2$time) & category1 == "Tradable services")
dp21_max_TG <- dp21 %>%
select(country, time, category1, category2, value_country) %>%
mutate(type = ifelse(str_detect(category2, "Lower"), "Lower half", "Upper half")) %>%
filter(time == max(dp21_2$time) & category1 == "Tradable goods")
dp21_max_TS <- dp21 %>%
select(country, time, category1, category2, value_country) %>%
mutate(type = ifelse(str_detect(category2, "Lower"), "Lower half", "Upper half")) %>%
filter(time == max(dp21_2$time) & category1 == "Tradable services")
data_plotly <- tibble(
"x" = c("Lower half", "Upper half"),
"y" = dp21_min_TG$value_country,
"y2" = dp21_min_TS$value_country,
"y3" = dp21_max_TG$value_country,
"y4" = dp21_max_TS$value_country,
"name1" = dp21_min_TG$category2,
"name2" = dp21_max_TG$category2
)
x <- c("Lower half", "Upper half")
y <- dp21_min_TG$value_country
y2 <- dp21_min_TS$value_country
y3 <- dp21_max_TG$value_country
y4 <- dp21_max_TS$value_country
name1 <- dp21_min_TG$category2
name2 <- dp21_max_TG$category2
p1 <- plot_ly() %>% add_trace(
x = ~x, y = ~y3, color = ~x,
type = "bar",
name = ~name2,
marker = list(
color = c("#c8f075","#6bc5f2")
)
)
p1 <- p1 %>% add_markers(
x = ~x, y = ~y, color = ~x,
name = ~name1,
mode = "markers",
marker = list(
color = clrs4[2:1],
size = 12,
symbol = "diamond-dot"
)
)
p1 <- p1 %>% layout(
title = "Tradable goods",
xaxis = list(title = "", visible = FALSE),
yaxis = list(title = "Employment share (%)")
)
p2 <- plot_ly() %>% add_trace(
x = ~x, y = ~y4, color = ~x,
type = "bar",
marker = list(color = c("#c8f075","#6bc5f2")),
showlegend = FALSE
)
p2 <- p2 %>% add_markers(
x = ~x, y = ~y2, color = ~x,
mode = "markers",
marker = list(
color = clrs4[2:1],
size = 12,
symbol = "diamond-dot"
),
showlegend = FALSE
)
p2 <- p2 %>% layout(
title = "Tradable services",
xaxis = list(title = "", visible = FALSE),
yaxis = list(title = "Employment share (%)")
)
fig3 <- subplot(p1, p2, nrows = 1, margin = 0.05, shareX = TRUE, shareY = TRUE)
fig3 <- fig3 %>%
layout(
title = list(text = "Figure 3: Share of workers in most productive (tradable) sectors,\nTL2 regions", x = 0),
margin = list(
l = 50, r = 50,
b = 50, t = 120,
pad = 4
),
annotations = list(
list(
x = 0.25,
y = 1,
font = list(size = 14),
text = "Industry",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = FALSE
),
list(
x = 0.75,
y = 1,
font = list(size = 14),
text = "Tradable services",
xref = "paper",
yref = "paper",
xanchor = "center",
yanchor = "bottom",
showarrow = FALSE
)
)
)
```
```{r can_fig3_text}
dp2 <- read_excel("data/countryprofile_fig4_alt.xlsx", sheet = ctry) %>%
clean_names()
text_all <- dp2 %>%
filter(time == 2020) %>%
pull(text_all)
```
`r text_all`
```{r chl_fig3_2}
# put fig3 title in black
fig3 <- fig3 %>%
layout(
title = list(text = "Figure 3: Share of workers in most productive (tradable) sectors,\nTL2 regions",
x = 0,
xanchor = "left",
xref = "paper",
font = list(color = "black", family = "Arial"))
)
# remove legend background
fig3 <- fig3 %>%
layout(
legend = list(bgcolor = "rgba(0,0,0,0)")
)
fig3
```
<div class="oecdnote">
**Note**: A region is in the “upper half” if labour productivity was above the country median in the first year with available data and “lower half” if productivity was below the country median. The share of workers in a given sector for a group of regions is defined as the sum of employment in that sector within the group divided by the sum of total employment within the group. Regions are small (TL3) regions, except for Australia, Canada, Chile, Ireland, Mexico, Norway, Switzerland, Türkiye and the United States where they are large (TL2) regions due to data availability. Industry includes the following tradable goods sectors: Mining and quarrying (B), Manufacturing (C), Electricity, gas, steam and air conditioning supply (D) and Water supply; sewerage; waste management and remediation activities (E) NACE macro sectors. Tradable services include Information and communication (J), Financial and insurance activities (K), Real estate activities (L), Professional, scientific and technical activities (M), Administrative and support service activities (N).<br>
**Source**: OECD Regional Database (2022).
</div>
<br>
<br>
## Recent policy developments
```{r chl_txt}
read_html_text(ctry)
```
<table border="1" style="width:75%;margin-left:auto;margin-right:auto;">
<tr>
<th style="background:#d4edff; padding:10px;font-size:9.0pt;" valign="center">
Territorial definitions
</th>
</tr>
<tr>
<td>
<p style="padding-left:10px;padding-right:10px;padding-top:10px;font-size:9.0pt;">
The data in this note reflect different sub-national geographic levels in OECD countries. In particular, <b>regions</b> are classified on two territorial levels reflecting the administrative organisation of countries: large regions (TL2) and small regions (TL3).
</p>
<p style="padding-left:10px;padding-right:10px;font-size:9.0pt;">
Small regions are classified according to their access to metropolitan areas (Fadic et al. 2019). The typology classifies small (TL3) regions into metropolitan and non-metropolitan regions according to the following criteria:
</p>
<ul style="list-style-type:circle;font-size:9.0pt;padding-right:10px">
<li>
<b>Metropolitan regions</b>, if more than half of the population live in a FUA. Metropolitan regions are further classified into: <b>metropolitan large</b>, if more than half of the population live in a (large) FUA of at least 1.5 million inhabitants; and <b>metropolitan midsize</b>, if more than half of the population live in a (midsize) FUA of at 250 000 to 1.5 million inhabitants.
</li>
<li>
<b>Non-metropolitan regions</b>, if less than half of the population live in a midsize/large FUA. These regions are further classified according to their level of access to FUAs of different sizes: <b>near a midsize/large FUA</b> if more than half of the population live within a 60-minute drive from a midsize/large FUA (of more than 250 000 inhabitants) or if the TL3 region contains more than 80% of the area of a midsize/large FUA; <b>near a small FUA</b> if the region does not have access to a midsize/large FUA and at least half of its population have access to a small FUA (i.e. between 50 000 and 250 000 inhabitants) within a 60-minute drive, or contains 80% of the area of a small FUA; and <b>remote</b>, otherwise.
</li>
</ul>
</p>
<p style="padding-left:10px;padding-right:10px;font-size:9.0pt;">
Disclaimer: <a href="https://oecdcode.org/disclaimers/territories.html" target="_blank"><i style="color:#0d6efd">https://oecdcode.org/disclaimers/territories.html</i></a>
</p>
</td>
</tr>
</table>