リビジョン | b054b5b0f13d72abe202d579dc73aeef05c7074f (tree) |
---|---|
日時 | 2024-06-11 02:45:28 |
作者 | Lorenzo Isella <lorenzo.isella@gmai...> |
コミッター | Lorenzo Isella |
I am translating the country fiche from markdown to quarto.
@@ -0,0 +1,1024 @@ | ||
1 | +--- | |
2 | +title: "My Document" | |
3 | +format: | |
4 | + docx: | |
5 | + toc: false | |
6 | + number-sections: true | |
7 | + highlight-style: github | |
8 | +execute: | |
9 | + echo: false | |
10 | + warning: false | |
11 | + message: false | |
12 | +--- | |
13 | + | |
14 | + | |
15 | +```{r, scoreboard, echo=FALSE, eval=TRUE} | |
16 | + | |
17 | + | |
18 | +options( scipen = 16 ) | |
19 | + | |
20 | +## options(tidyverse.quiet = TRUE) | |
21 | +## suppressWarnings(suppressMessages(library(janitor))) | |
22 | +## suppressWarnings(suppressMessages(library(viridis))) | |
23 | +## suppressWarnings(suppressMessages(library(scales))) | |
24 | +## suppressWarnings(suppressMessages(library(treemap))) | |
25 | +## suppressWarnings(suppressMessages(library(ggsci))) | |
26 | +## suppressWarnings(suppressMessages(library(flextable))) | |
27 | +## suppressWarnings(suppressMessages(library(readr))) | |
28 | + | |
29 | +## options(message = FALSE) | |
30 | + | |
31 | + | |
32 | +library(tidyverse, warn.conflicts = FALSE) | |
33 | +library(janitor) | |
34 | +library(viridis) | |
35 | +library(scales) | |
36 | +library(treemap) | |
37 | +library(ggsci) | |
38 | +library(flextable) | |
39 | + | |
40 | +source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R") | |
41 | + | |
42 | + | |
43 | + | |
44 | + | |
45 | + ## Suppress summarise info | |
46 | +options(dplyr.summarise.inform = FALSE) | |
47 | + | |
48 | + | |
49 | +source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R") | |
50 | + | |
51 | + | |
52 | +MS <- "AUT" ## state | |
53 | + | |
54 | +cutoff <- 4 ## cutoff for keeping some expenditure objectives | |
55 | + | |
56 | +ms3 <- iso_map_eu27 |> | |
57 | + filter(iso3==MS) |> | |
58 | + pull(country) |> | |
59 | + as.character() | |
60 | + | |
61 | +covid_years <- c(2020, 2021, 2022) | |
62 | + | |
63 | +ukraine_years <- c(2022) | |
64 | + | |
65 | + | |
66 | + | |
67 | +scoreboard <- readRDS("../scoreboard.RDS") |> | |
68 | + filter(!is.na(aid_element_eur)) |> | |
69 | + mutate(case_type=if_else(case_number=="SA.38701", "Notified Aid", | |
70 | + case_type)) |> | |
71 | + rename("year"="expenditure_year", | |
72 | + "amount_spent_aid_element_in_eur_million" ="aid_element_eur", | |
73 | + "case_no"="case_number", | |
74 | + "procedure_name"="case_type", | |
75 | + "all_objective_names_gber_only"= "all_gber_obj", | |
76 | + "aid_instrument_name"="aid_instrument") |> | |
77 | + filter(amount_spent_aid_element_in_eur_million>0) | |
78 | + | |
79 | + | |
80 | + | |
81 | + | |
82 | +scoreboard_ms <- scoreboard |> | |
83 | + filter(member_state_3_letter_codes==MS) | |
84 | + | |
85 | +year_focus <- scoreboard_ms |> | |
86 | + pull(year) |> | |
87 | + max() | |
88 | + | |
89 | + | |
90 | +ini_focus <- year_focus-10 | |
91 | + | |
92 | + | |
93 | +cases <- scoreboard_ms |> | |
94 | + filter(year==max(year), | |
95 | + ## duration_end>=max(year), | |
96 | + amount_spent_aid_element_in_eur_million>0 | |
97 | + ) |> | |
98 | + select(member_state_3_letter_codes,case_no, year,amount_spent_aid_element_in_eur_million, | |
99 | + procedure_name) |> | |
100 | + ## filter(grepl("SA.", case_no)) %>% | |
101 | + distinct(case_no,.keep_all =T ) | |
102 | + | |
103 | + | |
104 | + | |
105 | + | |
106 | + | |
107 | +total_amount_eu27 <- scoreboard |> | |
108 | + filter(year==max(year), | |
109 | + ## duration_end>=max(year), | |
110 | + amount_spent_aid_element_in_eur_million>0, | |
111 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
112 | + ) |> | |
113 | + summarise(total=sum(amount_spent_aid_element_in_eur_million)) | |
114 | + | |
115 | +total_amount_eu27_covid_years <- scoreboard |> | |
116 | + filter(year %in% covid_years, | |
117 | + ## duration_end>=max(year), | |
118 | + amount_spent_aid_element_in_eur_million>0, | |
119 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
120 | + ) |> | |
121 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), | |
122 | + .by=year) |> | |
123 | + mutate(country="EU27") | |
124 | + | |
125 | + | |
126 | + | |
127 | +total_amount_eu27_ukraine_years <- scoreboard |> | |
128 | + filter(year %in% ukraine_years, | |
129 | + ## duration_end>=max(year), | |
130 | + amount_spent_aid_element_in_eur_million>0, | |
131 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
132 | + ) |> | |
133 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), | |
134 | + .by=year) |> | |
135 | + mutate(country="EU27") | |
136 | + | |
137 | + | |
138 | + | |
139 | + | |
140 | + | |
141 | +total_amount_eu27_covid <- scoreboard |> | |
142 | + filter(year==max(year), | |
143 | + ## all_intq %in% covid_qualifiers, | |
144 | + covid==T, | |
145 | + ## duration_end>=max(year), | |
146 | + amount_spent_aid_element_in_eur_million>0, | |
147 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
148 | + ) |> | |
149 | + summarise(total=sum(amount_spent_aid_element_in_eur_million)) |> | |
150 | + ungroup() | |
151 | + | |
152 | +total_amount_eu27_ukraine <- scoreboard |> | |
153 | + filter(year==max(year), | |
154 | + ## all_intq %in% covid_qualifiers, | |
155 | + ukraine==T, | |
156 | + ## duration_end>=max(year), | |
157 | + amount_spent_aid_element_in_eur_million>0, | |
158 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
159 | + ) |> | |
160 | + summarise(total=sum(amount_spent_aid_element_in_eur_million)) |> | |
161 | + ungroup() | |
162 | + | |
163 | + | |
164 | + | |
165 | + | |
166 | + | |
167 | +total_amount_eu27_covid_covid_years <- scoreboard |> | |
168 | + filter(year %in% covid_years, | |
169 | + ## all_intq %in% covid_qualifiers, | |
170 | + covid==T, | |
171 | + ## duration_end>=max(year), | |
172 | + amount_spent_aid_element_in_eur_million>0, | |
173 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
174 | + ) |> | |
175 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), .by=c(year)) |> | |
176 | + mutate(country="EU27") | |
177 | + | |
178 | + | |
179 | +total_amount_eu27_ukraine_ukraine_years <- scoreboard |> | |
180 | + filter(year %in% ukraine_years, | |
181 | + ## all_intq %in% covid_qualifiers, | |
182 | + ukraine==T, | |
183 | + ## duration_end>=max(year), | |
184 | + amount_spent_aid_element_in_eur_million>0, | |
185 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
186 | + ) |> | |
187 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), .by=c(year)) |> | |
188 | + mutate(country="EU27") | |
189 | + | |
190 | + | |
191 | + | |
192 | + | |
193 | +total_amount_MS <- scoreboard %>% | |
194 | + filter(year==max(year), | |
195 | + member_state_3_letter_codes==MS, | |
196 | + ## duration_end>=max(year), | |
197 | + amount_spent_aid_element_in_eur_million>0, | |
198 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
199 | + ) %>% | |
200 | + summarise(total=sum(amount_spent_aid_element_in_eur_million)) |> | |
201 | + ungroup() | |
202 | + | |
203 | + | |
204 | +total_amount_MS_covid <- scoreboard |> | |
205 | + filter(year==max(year), | |
206 | + member_state_3_letter_codes==MS, | |
207 | + ## all_intq %in% covid_qualifiers, | |
208 | + covid==T, | |
209 | + ## duration_end>=max(year), | |
210 | + amount_spent_aid_element_in_eur_million>0, | |
211 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
212 | + ) |> | |
213 | + summarise(total=sum(amount_spent_aid_element_in_eur_million)) |> | |
214 | + ungroup() | |
215 | + | |
216 | + | |
217 | + | |
218 | +total_amount_MS_ukraine <- scoreboard |> | |
219 | + filter(year==max(year), | |
220 | + member_state_3_letter_codes==MS, | |
221 | + ## all_intq %in% covid_qualifiers, | |
222 | + ukraine==T, | |
223 | + ## duration_end>=max(year), | |
224 | + amount_spent_aid_element_in_eur_million>0, | |
225 | + member_state_3_letter_codes %in% iso_map_eu27$iso3 | |
226 | + ) |> | |
227 | + summarise(total=sum(amount_spent_aid_element_in_eur_million)) |> | |
228 | + ungroup() | |
229 | + | |
230 | + | |
231 | + | |
232 | +covid_summary <- total_amount_eu27 |> | |
233 | + rename("total_eu"="total") |> | |
234 | + mutate(total_eu27_covid=total_amount_eu27_covid$total, | |
235 | + total_ms=total_amount_MS$total, | |
236 | + total_ms_covid=total_amount_MS_covid$total) |> | |
237 | + mutate(eu_covid_percentage=total_eu27_covid/total_eu, | |
238 | + ms_covid_percentage=total_ms_covid/total_ms) | |
239 | + | |
240 | + | |
241 | + | |
242 | + | |
243 | +ukraine_summary <- total_amount_eu27 |> | |
244 | + rename("total_eu"="total") |> | |
245 | + mutate(total_eu27_ukraine=total_amount_eu27_ukraine$total, | |
246 | + total_ms=total_amount_MS$total, | |
247 | + total_ms_ukraine=total_amount_MS_ukraine$total) |> | |
248 | + mutate(eu_ukraine_percentage=total_eu27_ukraine/total_eu, | |
249 | + ms_ukraine_percentage=total_ms_ukraine/total_ms) | |
250 | + | |
251 | + | |
252 | +covid_summary_print <- covid_summary |> | |
253 | + mutate(across(starts_with("total"), ~ ifelse(.x>1e3, | |
254 | + paste("EUR",round(.x/1e3,1), "billion", sep=" "), | |
255 | + paste("EUR", round(.x,1), "million", sep=" ") ))) | |
256 | + | |
257 | + | |
258 | + | |
259 | +ukraine_summary_print <- ukraine_summary |> | |
260 | + mutate(across(starts_with("total"), ~ ifelse(.x>1e3, | |
261 | + paste("EUR",round(.x/1e3,1), "billion", sep=" "), | |
262 | + paste("EUR", round(.x,1), "million", sep=" ") ))) | |
263 | + | |
264 | + | |
265 | +covid_summary_long <- covid_summary |> | |
266 | + select(contains("percentage")) |> | |
267 | + pivot_longer(cols = c(eu_covid_percentage , | |
268 | + ms_covid_percentage | |
269 | + ) , names_to= "country", values_to="covid_percentage" ) |> | |
270 | + mutate(ll=format_col(covid_percentage*100,1)) |> | |
271 | + mutate(ll=paste(ll, "%", sep="")) |> | |
272 | + arrange(country) |> | |
273 | + mutate(country=fct_inorder(country)) | |
274 | + | |
275 | + | |
276 | + | |
277 | +ukraine_summary_long <- ukraine_summary |> | |
278 | + select(contains("percentage")) |> | |
279 | + pivot_longer(cols = c(eu_ukraine_percentage , | |
280 | + ms_ukraine_percentage | |
281 | + ) , names_to= "country", values_to="ukraine_percentage" ) |> | |
282 | + mutate(ll=format_col(ukraine_percentage*100,1)) |> | |
283 | + mutate(ll=paste(ll, "%", sep="")) |> | |
284 | + arrange(country) |> | |
285 | + mutate(country=fct_inorder(country)) | |
286 | + | |
287 | + | |
288 | + | |
289 | + | |
290 | +n_cases <- nrow(cases) | |
291 | + | |
292 | +stat_cases <- cases |> | |
293 | + tabyl(procedure_name) |> | |
294 | + mutate(percent=round_preserve_sum(percent*100,1)) |> | |
295 | + add_total() |> | |
296 | + mutate(percent=format_col(percent,1)) |> | |
297 | + mutate(percent=paste(percent, "%", sep="")) | |
298 | + | |
299 | + | |
300 | +old_cases <- scoreboard |> | |
301 | + filter(year>=ini_focus, year!= year_focus, member_state_3_letter_codes==MS) | |
302 | + | |
303 | +new_cases_list <- setdiff(cases$case_no, old_cases$case_no) | |
304 | + | |
305 | +cases_new <- scoreboard_ms |> | |
306 | + filter(case_no %in% new_cases_list , | |
307 | + ## duration_end>=max(year), | |
308 | + amount_spent_aid_element_in_eur_million>0 | |
309 | + ) |> | |
310 | + select(member_state_3_letter_codes,case_no, year,amount_spent_aid_element_in_eur_million, | |
311 | + procedure_name) |> | |
312 | + ## filter(grepl("SA.", case_no)) %>% | |
313 | + distinct(case_no,.keep_all =T ) | |
314 | + | |
315 | +stat_cases_new <- cases_new |> | |
316 | + tabyl(procedure_name) |> | |
317 | + mutate(percent=round(percent*100,1)) | |
318 | + | |
319 | + | |
320 | +if (nrow(stat_cases_new)==0){ | |
321 | + stat_cases_new <- stat_cases_new |> | |
322 | + add_row(percent=0) | |
323 | + | |
324 | + | |
325 | +} | |
326 | + | |
327 | +stat_cases2 <- scoreboard |> | |
328 | + filter(year>=ini_focus, member_state_3_letter_codes==MS, | |
329 | + amount_spent_aid_element_in_eur_million>0, | |
330 | + procedure_name!="Fisheries Block Exemption Regulation") |> | |
331 | + group_by(year, procedure_name) |> | |
332 | + summarise(expenditure=sum(amount_spent_aid_element_in_eur_million/1e3), | |
333 | + expenditure_deflated=sum(aid_element_eur_adj/1e3) | |
334 | + ) |> | |
335 | + ungroup() | |
336 | + | |
337 | + | |
338 | + | |
339 | +stat_cases3 <- scoreboard |> | |
340 | + filter(year>=ini_focus, member_state_3_letter_codes==MS, | |
341 | + amount_spent_aid_element_in_eur_million>0) |> | |
342 | + ## mutate(procedure2=if_else(procedure_name=="General Block Exemption Regulation", "(G)BER", procedure_name)) %>% | |
343 | + group_by( procedure_name) |> | |
344 | + summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)/1e3) |> | |
345 | + ungroup() |> | |
346 | + mutate(expenditure=round_preserve_sum(expenditure, 1)) |> | |
347 | + mutate(percent=expenditure/sum(expenditure)*100) |> | |
348 | + mutate(percent=round_preserve_sum(percent,1)) |> | |
349 | + add_total() |> | |
350 | + mutate(percent=format_col(percent,1), | |
351 | + expenditure=format_col(expenditure,1)) |> | |
352 | + mutate(percent=paste(percent,"%", sep="")) |> | |
353 | + mutate(expenditure=if_else(expenditure!="0.0", expenditure,"less than 0.1"), | |
354 | + percent=if_else(percent!="0.0%", percent, "less than 0.1%")) | |
355 | + | |
356 | + | |
357 | + | |
358 | + | |
359 | + | |
360 | + | |
361 | +top5 <- scoreboard_ms |> | |
362 | + filter(year==max(year)) |> | |
363 | + group_by(case_no) |> | |
364 | + summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) %>% | |
365 | + ungroup() |> | |
366 | + arrange(desc(expenditure)) |> | |
367 | + mutate(share=expenditure/sum(expenditure)) |> | |
368 | + slice(1:5) |> | |
369 | + mutate(cum_share=cumsum(share), | |
370 | + cum_expenditure=cumsum(expenditure)) |> | |
371 | + filter(expenditure>0) | |
372 | + | |
373 | + | |
374 | + | |
375 | + | |
376 | +top5_share <- top5 |> | |
377 | + pull(cum_share) |> | |
378 | + max() |> | |
379 | + multiply_by(100) |> | |
380 | + round(1) | |
381 | + | |
382 | + | |
383 | +top5_expenditure <- top5 |> | |
384 | + pull(cum_expenditure) |> | |
385 | + max() | |
386 | + | |
387 | +if (top5_expenditure>1e3){ | |
388 | + | |
389 | + top5_expenditure_print <- top5_expenditure |> | |
390 | + divide_by(1e3) |> | |
391 | + round(1) |> | |
392 | + paste("EUR ", x=_, " billion", sep="") | |
393 | + | |
394 | + | |
395 | +} else{ | |
396 | + | |
397 | + top5_expenditure_print <- top5_expenditure |> | |
398 | + ## divide_by(1e3) |> | |
399 | + round(1) |> | |
400 | + paste("EUR ", x=_, "million", sep="") | |
401 | + | |
402 | + | |
403 | +} | |
404 | + | |
405 | + | |
406 | +total_expenditure <- scoreboard_ms |> | |
407 | + filter(year>=ini_focus) |> | |
408 | + pull(amount_spent_aid_element_in_eur_million) |> | |
409 | + sum(na.rm=T) ## |> divide_by(1e3) |> | |
410 | + ## round(1) | |
411 | + | |
412 | +if (total_expenditure>1e3) { total_expenditure_temp <- total_expenditure |> | |
413 | + divide_by(1e3) |> | |
414 | + round(1) | |
415 | +total_expenditure_print <- paste("EUR", total_expenditure_temp, "billion", sep=" ") | |
416 | + | |
417 | +} else { total_expenditure_temp <- total_expenditure |> | |
418 | + round(1) | |
419 | + | |
420 | + total_expenditure_print <- paste("EUR", total_expenditure_temp, "million", sep=" ") | |
421 | + | |
422 | + | |
423 | +} | |
424 | + | |
425 | + | |
426 | + | |
427 | +total_expenditure_last <- scoreboard_ms |> | |
428 | + filter(year==year_focus) |> | |
429 | + pull(amount_spent_aid_element_in_eur_million) |> | |
430 | + sum(na.rm=T) | |
431 | + | |
432 | +if (total_expenditure>1e3){ | |
433 | + total_expenditure_last_print <- total_expenditure_last |> | |
434 | + divide_by(1e3) |> | |
435 | + round(1) |> | |
436 | + paste("EUR", x=_ ,"million", sep=" " ) | |
437 | + | |
438 | +} else { | |
439 | + | |
440 | + total_expenditure_last_print <- total_expenditure_last |> | |
441 | + round(1) |> | |
442 | + paste("EUR", x=_ ,"million", sep=" " ) | |
443 | + | |
444 | + | |
445 | +} | |
446 | + | |
447 | + | |
448 | +cofinancing <- scoreboard_ms |> | |
449 | + filter( year==max(year), | |
450 | + ## duration_end>=max(year), | |
451 | + amount_spent_aid_element_in_eur_million>0 | |
452 | + ) |> | |
453 | + mutate(expenditure=amount_spent_aid_element_in_eur_million* | |
454 | + co_financed) | |
455 | + | |
456 | + | |
457 | + | |
458 | + | |
459 | + | |
460 | +cofinancing_expenditure <- cofinancing |> | |
461 | + pull(expenditure) |> | |
462 | + sum() | |
463 | + | |
464 | +if (cofinancing_expenditure>1e3){ | |
465 | + | |
466 | + cofinancing_expenditure_temp <- cofinancing_expenditure |> | |
467 | + divide_by(1e3) |> | |
468 | + round(1) | |
469 | + | |
470 | + cofinancing_expenditure_print <- paste("EUR",cofinancing_expenditure_temp, | |
471 | + "billion", sep=" ") | |
472 | + | |
473 | +} else { cofinancing_expenditure_temp <- cofinancing_expenditure |> | |
474 | + round(1) | |
475 | + | |
476 | + cofinancing_expenditure_print <- paste("EUR",cofinancing_expenditure_temp, | |
477 | + "million", sep=" ") | |
478 | + | |
479 | + | |
480 | +} | |
481 | + | |
482 | + | |
483 | + | |
484 | +## share_cofinancing <- round(cofinancing_expenditure/1e3/total_expenditure_last | |
485 | +## *100,1) | |
486 | + | |
487 | + | |
488 | +share_cofinancing <- round(cofinancing_expenditure/total_expenditure_last | |
489 | + *100,1) | |
490 | + | |
491 | + | |
492 | + | |
493 | +cofinancing_objective <- cofinancing |> | |
494 | + group_by(scoreboard_objective) |> | |
495 | + summarise(expenditure_objective=sum(expenditure)) |> | |
496 | + ungroup() |> | |
497 | + arrange(desc(expenditure_objective)) |> | |
498 | + mutate(share=expenditure_objective/sum(expenditure_objective)*100) |> | |
499 | + mutate(share=round_preserve_sum(share,1)) | |
500 | + | |
501 | +## list_obj <- cofinancing_objective |> | |
502 | +## filter(share>=cutoff) | |
503 | + | |
504 | + | |
505 | +cofinancing_objective_sel <- cofinancing_objective |> | |
506 | + mutate(top_objective = fct_lump_min(scoreboard_objective,cutoff,share )) |> | |
507 | + summarise(expenditure=sum(expenditure_objective), .by=c(top_objective)) |> | |
508 | + mutate(top_objective=fct_inorder(top_objective)) |> | |
509 | + mutate(top_objective=fct_relevel(top_objective, "Other", after = Inf)) | |
510 | + | |
511 | + | |
512 | +expenditure_by_objective <- scoreboard_ms |> | |
513 | + filter(year==max(year), | |
514 | + ## duration_end>=max(year), | |
515 | + amount_spent_aid_element_in_eur_million>0 | |
516 | + ) |> | |
517 | + mutate(scoreboard_objective=recode(scoreboard_objective, | |
518 | + "Other"="Other policy objectives" )) |> | |
519 | + group_by(scoreboard_objective) |> | |
520 | + summarise(expenditure_objective=sum(amount_spent_aid_element_in_eur_million)) |> | |
521 | + ungroup() |> | |
522 | + arrange(desc(expenditure_objective)) |> | |
523 | + mutate(objectives_reduced=if_else(scoreboard_objective %in% scoreboard_objective[1:4], scoreboard_objective, "Other policy objectives" )) |> | |
524 | + group_by(objectives_reduced) |> | |
525 | + summarise(expenditure2=sum(expenditure_objective)) |> | |
526 | + ungroup() |> | |
527 | + arrange(desc(expenditure2)) |> | |
528 | + mutate(share=expenditure2/sum(expenditure2)) |> | |
529 | + mutate(share2=round_preserve_sum(share*100,1)) |> | |
530 | + mutate(share_label=paste(as.character(share2), "%", sep="")) |> | |
531 | + (\(.) move_row(.,which(.$objectives_reduced=="Other policy objectives"), nrow(.)))() |> | |
532 | + ## move_row(which(.$objectives_reduced=="Other policy objectives"), nrow(.)) |> | |
533 | + ## mutate(objectives_reduced=wrapper1(objectives_reduced, 25)) %>% | |
534 | + mutate(objectives_reduced=factor(objectives_reduced)) |> | |
535 | + mutate(objectives_reduced=fct_inorder(objectives_reduced)) | |
536 | + | |
537 | +expenditure_gber <- scoreboard_ms |> | |
538 | + filter(year==max(year), | |
539 | + ## duration_end>=max(year), | |
540 | + amount_spent_aid_element_in_eur_million>0 | |
541 | + ) |> | |
542 | + filter(!is.na(all_objective_names_gber_only)) |> | |
543 | + group_by(all_objective_names_gber_only) |> | |
544 | + summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) |> | |
545 | + ungroup() |> | |
546 | + arrange(desc(expenditure)) |> | |
547 | + mutate(share=expenditure/sum(expenditure)) |> | |
548 | + mutate(share2=round_preserve_sum(share*100,1)) | |
549 | + | |
550 | +expenditure_gber_print <- expenditure_gber |> | |
551 | + select(all_objective_names_gber_only, share) |> | |
552 | + mutate(share=round_preserve_sum(share*100,1)) |> | |
553 | + slice(1:4) |> | |
554 | + add_total(name="Total top 4 GBER articles") |> | |
555 | + mutate(share=format_col_percentage(share,1)) | |
556 | + | |
557 | + | |
558 | + | |
559 | + | |
560 | +expenditure_aid <- scoreboard_ms |> | |
561 | + filter(year==max(year), | |
562 | + ## duration_end>=max(year), | |
563 | + amount_spent_aid_element_in_eur_million>0 | |
564 | + ) |> | |
565 | + filter(!is.na(harmonised_aid_instrument)) |> | |
566 | + group_by(harmonised_aid_instrument) |> | |
567 | + summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) |> | |
568 | + ungroup() |> | |
569 | + arrange(desc(expenditure)) |> | |
570 | + mutate(share=expenditure/sum(expenditure)) |> | |
571 | + mutate(share2=round_preserve_sum(share*100,1)) |> | |
572 | + mutate(expenditure2=round(expenditure,0)) |> | |
573 | + mutate(expenditure_print=ifelse(expenditure>1e3, expenditure/1e3, | |
574 | + expenditure)) |> | |
575 | + mutate(expenditure_print=round(expenditure_print, 1)) |> | |
576 | + mutate(expenditure_print=ifelse(expenditure>1e3, | |
577 | + paste("EUR",expenditure_print, "billion", sep=" " ), | |
578 | + paste("EUR",expenditure_print, "million", sep=" " ) | |
579 | + )) | |
580 | + | |
581 | + | |
582 | + | |
583 | + | |
584 | +expenditure_aid_sel <- expenditure_aid |> | |
585 | + mutate(top_instrument=fct_lump_min(harmonised_aid_instrument,cutoff/100,share )) |> | |
586 | + summarise(expenditure=sum(expenditure), .by=c(top_instrument)) |> | |
587 | + arrange(desc(expenditure)) |> | |
588 | + mutate(top_instrument=fct_inorder(top_instrument)) |> | |
589 | + mutate(top_instrument=fct_relevel(top_instrument, "Other", after = Inf)) | |
590 | + | |
591 | + | |
592 | + | |
593 | + | |
594 | +covid_eu27_year <- total_amount_eu27_covid_covid_years |> | |
595 | + mutate(share= total/total_amount_eu27_covid_years$total) | |
596 | + | |
597 | + | |
598 | +ukraine_eu27_year <- total_amount_eu27_ukraine_ukraine_years |> | |
599 | + mutate(share= total/total_amount_eu27_ukraine_years$total) | |
600 | + | |
601 | + | |
602 | + | |
603 | +covid_years_ms <- scoreboard_ms |> | |
604 | + filter(year %in% covid_years) |> | |
605 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), | |
606 | + .by=year) | |
607 | + | |
608 | + | |
609 | + | |
610 | +ukraine_years_ms <- scoreboard_ms |> | |
611 | + filter(year %in% ukraine_years) |> | |
612 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), | |
613 | + .by=year) | |
614 | + | |
615 | + | |
616 | + | |
617 | +covid_years_ms_covid <- scoreboard_ms |> | |
618 | + filter(year %in% covid_years, | |
619 | + covid==T ) |> | |
620 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), | |
621 | + .by=year) | |
622 | + | |
623 | + | |
624 | + | |
625 | + | |
626 | +ukraine_years_ms_ukraine <- scoreboard_ms |> | |
627 | + filter(year %in% ukraine_years, | |
628 | + ukraine==T ) |> | |
629 | + summarise(total=sum(amount_spent_aid_element_in_eur_million), | |
630 | + .by=year) | |
631 | + | |
632 | + | |
633 | + | |
634 | +covid_ms_year <- covid_years_ms_covid |> | |
635 | + mutate(share=total/covid_years_ms$total, | |
636 | + country=ms3) | |
637 | + | |
638 | +ukraine_ms_year <- ukraine_years_ms_ukraine |> | |
639 | + mutate(share=total/ukraine_years_ms$total, | |
640 | + country=ms3) | |
641 | + | |
642 | + | |
643 | + | |
644 | +output_covid <- bind_rows(covid_eu27_year, | |
645 | + covid_ms_year) |> | |
646 | + mutate(percent=format_col_preserve_sum(share*100,1)) |> | |
647 | + mutate(percent=paste(percent, "%", sep="")) |> | |
648 | + mutate(year=as.factor(year)) |> | |
649 | + mutate(country=factor(country)) |> | |
650 | + mutate(country=fct_relevel(country, "EU27")) |> | |
651 | + mutate(total_print=ifelse(total>1e3, | |
652 | + paste("EUR",round(total/1e3,1), "billion", sep=" "), | |
653 | + paste("EUR", round(total,1), "million", sep=" "))) |> | |
654 | + mutate(total_print=ifelse(total>1e3, | |
655 | + paste("EUR",round(total/1e3,1), "billion", sep=" "), | |
656 | + paste("EUR", round(total,1), "million", | |
657 | + sep=" "))) | |
658 | + | |
659 | + | |
660 | +output_ukraine <- bind_rows(ukraine_eu27_year, | |
661 | + ukraine_ms_year) |> | |
662 | + mutate(percent=format_col_preserve_sum(share*100,1)) |> | |
663 | + mutate(percent=paste(percent, "%", sep="")) |> | |
664 | + mutate(year=as.factor(year)) |> | |
665 | + mutate(country=factor(country)) |> | |
666 | + mutate(country=fct_relevel(country, "EU27")) |> | |
667 | + mutate(total_print=ifelse(total>1e3, | |
668 | + paste("EUR",round(total/1e3,1), "billion", sep=" "), | |
669 | + paste("EUR", round(total,1), "million", sep=" "))) |> | |
670 | + mutate(total_print=ifelse(total>1e3, | |
671 | + paste("EUR",round(total/1e3,1), "billion", sep=" "), | |
672 | + paste("EUR", round(total,1), "million", sep=" "))) | |
673 | + | |
674 | + | |
675 | + | |
676 | +``` | |
677 | + | |
678 | +--- | |
679 | +title: "Country Focus on `r ms3` in `r year_focus`" | |
680 | +--- | |
681 | + | |
682 | +In this document, unless otherwise stated, the reported State aid expenditure always | |
683 | +excludes aid expenditure to railways and to financial institutions. | |
684 | + | |
685 | +# Case and Procedural Information | |
686 | +The total number of active measures corresponded to `r n_cases` in | |
687 | +`r year_focus` and the detailed breakdown by type of measure is provided | |
688 | +in Table \@ref(tab:tab1). | |
689 | + | |
690 | + | |
691 | +<!-- See https://ardata-fr.github.io/flextable-book/captions-and-cross-references.html --> | |
692 | + | |
693 | +```{r, tab.cap="Number and share of State aid measures by type of procedure.", tab.id='tab1', label='tab1' , echo=FALSE, eval=TRUE} | |
694 | + | |
695 | + | |
696 | + | |
697 | +ft <- stat_cases |> | |
698 | + flextable() |> | |
699 | + ## add_header_row(values = c(paste("State Aid Measures in ", year_focus, sep="")) ) %>% | |
700 | + set_header_labels(procedure_name="Type of Procedure", | |
701 | + n="Number of Active Measures", | |
702 | + percent="Share of Total" | |
703 | + ) |> | |
704 | + theme_zebra() |> | |
705 | + fontsize(part = "all", size = 8) |> | |
706 | + font(part="all", fontname = "Verdana") |> | |
707 | + colformat_double(big.mark = " ") |> | |
708 | + ## autofit() ## %>% | |
709 | + width(width = c(2,2,2)) | |
710 | +ft <- add_header_row( | |
711 | + x = ft, values = paste("State Aid Measures in ",year_focus, sep=""), | |
712 | + colwidths = c(3)) | |
713 | +ft <- theme_box(ft) |> | |
714 | + align(align="center", part="header") |> | |
715 | + align(align = "right",j=c(2,3), part="body") ## |> | |
716 | + ## set_caption("htftyhfghyfgh") | |
717 | +ft | |
718 | +``` | |
719 | + | |
720 | +In `r year_focus`, the number of GBER measures in `r ms3` reached | |
721 | +`r stat_cases[stat_cases$procedure_name=="General Block Exemption Regulation",]$percent` of the total number of measures, with | |
722 | +`r stat_cases_new[stat_cases_new$procedure_name=="General Block Exemption Regulation",]$percent`% of all newly implemented measured falling | |
723 | +under GBER. | |
724 | + | |
725 | +# State aid spending - Overview | |
726 | + | |
727 | +Figure \@ref(fig:spending) illustrates the evolution of the | |
728 | +State aid expenditure, broken down by type of procedure, for `r ms3` during the period | |
729 | +`r ini_focus`-`r year_focus` in constant prices adjusted by the yearly | |
730 | +value of GDP(with the exclusion of aid under the fisheries block exemption | |
731 | +regulation because it is negligible compared to the aid given under | |
732 | +the other type of procedures). | |
733 | + | |
734 | + | |
735 | + | |
736 | +```{r spending, echo=FALSE,fig.cap="State aid expenditure at constant prices by type of procedure.",fig.height = 6, fig.width = 12} | |
737 | + | |
738 | + | |
739 | +## my_pal <- viridis(length(stat_cases2 %>% pull(procedure_name) %>% | |
740 | +## unique)+1)[1:4] | |
741 | + | |
742 | + | |
743 | + | |
744 | +my_pal <- pal_npg("nrc")(4) | |
745 | + | |
746 | +ggplot(data = stat_cases2, aes(x = year, y=expenditure_deflated, | |
747 | + fill=procedure_name)) + | |
748 | + geom_bar(position=position_dodge2(preserve="single"), stat="identity", alpha=1, color="black")+ | |
749 | + ## scale_fill_viridis("Vehicle Brand\nOrigin",breaks=mybreaks, labels= mylabels, discrete=T)+ | |
750 | + ## scale_colour_viridis("Vehicle Brand\nOrigin",breaks=mybreaks, labels= mylabels, discrete=T)+ | |
751 | + | |
752 | + scale_fill_manual(NULL, ## labels=c("Inward Stocks","Outward Stocks" ), | |
753 | + values=my_pal)+ | |
754 | + | |
755 | + | |
756 | + ## coord_cartesian(ylim = c(0, 20)) + | |
757 | + my_ggplot_theme2("top")+ | |
758 | + ## theme(legend.position = 'top', | |
759 | + ## legend.spacing.x = unit(1.0, 'cm'))+ | |
760 | +## theme(axis.text.x = element_text(size=15,angle=90, colour="black", vjust=1))+ | |
761 | + | |
762 | + labs(title=paste("State aid spending in billion EUR ",ini_focus, "-", | |
763 | + year_focus, " (constant prices)", sep=""))+ | |
764 | + scale_x_continuous(breaks=seq(ini_focus, year_focus))+ | |
765 | +## coord_cartesian(ylim=c(0,8000))+ | |
766 | +## scale_y_continuous(sec.axis = sec_axis(~./norm_in, labels=mypercentlatex, | |
767 | +## name="Percentage of\nTotal Extra EU28", | |
768 | +## breaks=seq(0, 1, by=0.2)))+ | |
769 | +## scale_y_continuous(labels=mypercentlatex)+ | |
770 | + | |
771 | + xlab(NULL)+ | |
772 | + ylab("State aid expenditure (EUR bn)")+ | |
773 | + guides(fill=guide_legend(nrow=1,byrow=TRUE)) | |
774 | +``` | |
775 | + | |
776 | + | |
777 | +In `r year_focus`, the total State aid spending for `r ms3` amounted | |
778 | + to `r total_expenditure_last_print`. The 5 biggest State aid | |
779 | + measures in absorbed `r top5_share`% of the total spending i.e. `r top5_expenditure_print`. | |
780 | + | |
781 | + Finally, the amount of aid co-financed with EU funds in `r ms3` corresponded to | |
782 | + `r cofinancing_expenditure_print` <!-- million EUR --> (around | |
783 | + `r share_cofinancing`% of the total spending) and | |
784 | + was mostly concentrated in | |
785 | + `r cofinancing_objective$scoreboard_objective[1]` | |
786 | + (`r cofinancing_objective$share[1]`%), | |
787 | + `r cofinancing_objective$scoreboard_objective[2]` | |
788 | + (`r cofinancing_objective$share[2]`%) and | |
789 | + `r cofinancing_objective$scoreboard_objective[3]` | |
790 | + (`r cofinancing_objective$share[3]`%). | |
791 | + | |
792 | +Figure \@ref(fig:topobjectives) illustrates the actual amount of the co-financed | |
793 | + aid for the most important co-financed objectives. | |
794 | + | |
795 | +```{r topobjectives, fig.cap="State expenditure for the main co-financed State aid objectives.", echo=FALSE,fig.height = 7, fig.width = 12} | |
796 | +ggplot(data = cofinancing_objective_sel, | |
797 | + aes(x = expenditure, y=fct_rev(top_objective))) + | |
798 | + geom_bar(position="dodge", stat="identity", alpha=1, color="black") + | |
799 | + ## geom_text(aes(label=share_label), position=position_dodge(width=0.9), | |
800 | + ## hjust=-.1, | |
801 | + ## vjust=-0.1, | |
802 | + ## size=5)+ | |
803 | + ## coord_cartesian(xlim = c(0, 1)) + | |
804 | + my_ggplot_theme2("top")+ | |
805 | + ## scale_x_continuous(labels = label_percent())+ | |
806 | + scale_y_discrete(labels = wrap_format(20))+ | |
807 | + xlab("State aid expenditure (million EUR)")+ | |
808 | + ylab(NULL)+ | |
809 | + labs(title=paste("Top State aid objectives for co-financed aid in ", | |
810 | + year_focus, sep="")) | |
811 | +``` | |
812 | + | |
813 | + | |
814 | + | |
815 | +# State aid spending: top objectives and instruments | |
816 | + | |
817 | + Around `r sum(expenditure_by_objective$share2[1:2])`% of State aid | |
818 | + spending in `r ms3` was concentrated in two main policy objectives. Around | |
819 | +`r expenditure_by_objective$share2[1]`% was directed towards | |
820 | +"`r expenditure_by_objective$objectives_reduced[1]`" while | |
821 | +`r expenditure_by_objective$share2[2]`% to | |
822 | +"`r expenditure_by_objective$objectives_reduced[2]`". | |
823 | + | |
824 | +Furthermore, `r ms3` devoted around | |
825 | +`r expenditure_by_objective$share2[3]`% towards | |
826 | +"`r expenditure_by_objective$objectives_reduced[3]`" and | |
827 | +`r expenditure_by_objective$share2[4]`% to | |
828 | +"`r expenditure_by_objective$objectives_reduced[4]`". | |
829 | + | |
830 | +The data is also illustrated in the Figure \@ref(fig:topobjectives2). | |
831 | + | |
832 | +```{r topobjectives2,fig.cap="Share of State aid expenditure for the main objectives.", echo=FALSE,fig.height = 6, fig.width = 12} | |
833 | +ggplot(data = expenditure_by_objective, | |
834 | + aes(x = share, y=fct_rev(objectives_reduced))) + | |
835 | + geom_bar(position="dodge", stat="identity", alpha=1, color="black") + | |
836 | + geom_text(aes(label=share_label), position=position_dodge(width=0.9), | |
837 | + hjust=-.1, | |
838 | + vjust=-0.1, | |
839 | + size=5)+ | |
840 | + coord_cartesian(xlim = c(0, 1)) + | |
841 | + my_ggplot_theme2("top")+ | |
842 | + scale_x_continuous(labels = label_percent())+ | |
843 | + scale_y_discrete(labels = wrap_format(20))+ | |
844 | + xlab("Share of State aid expenditure")+ | |
845 | + ylab(NULL)+ | |
846 | + labs(title=paste("Top State aid objectives in ", | |
847 | + year_focus, sep="")) | |
848 | +``` | |
849 | + | |
850 | + | |
851 | +As to GBER, the top 4 key articles absorbe about | |
852 | +`r sum(expenditure_gber$share2[1:4])`% | |
853 | +of the total GBER spending, as illustrated in Table | |
854 | +\@ref(tab:tab3). | |
855 | + | |
856 | + | |
857 | +```{r, tab.cap="Contribution of the top 4 GBER articles to the total GBER expenditure.", tab.id='tab3', label='tab3' , echo=FALSE, eval=TRUE} | |
858 | + | |
859 | + | |
860 | + | |
861 | +ft <- expenditure_gber_print |> | |
862 | + flextable() |> | |
863 | + ## add_header_row(values = c(paste("State Aid Measures in ", year_focus, sep="")) ) %>% | |
864 | + set_header_labels(all_objective_names_gber_only="GBER Article", | |
865 | + ## n="Number of Active Measures", | |
866 | + share="Share of Total" | |
867 | + ) |> | |
868 | + theme_zebra() |> | |
869 | + fontsize(part = "all", size = 8) |> | |
870 | + font(part="all", fontname = "Verdana") |> | |
871 | + colformat_double(big.mark = " ") |> | |
872 | + ## autofit() ## %>% | |
873 | + width(width = c(3,3)) | |
874 | +ft <- add_header_row( | |
875 | + x = ft, values = paste("Top GBER Articles in ",year_focus, sep=""), | |
876 | + colwidths = c(2)) | |
877 | +ft <- theme_box(ft) |> | |
878 | + align(align="center", part="header") |> | |
879 | + align(align = "right",j=c(2), part="body") ## |> | |
880 | +## ## set_caption("htftyhfghyfgh") | |
881 | +ft | |
882 | +``` | |
883 | + | |
884 | + | |
885 | + | |
886 | + | |
887 | + | |
888 | +<!-- ```{r topgber, fig.cap="Top GBER articles.", echo=FALSE,fig.height = 8, fig.width = 12} --> | |
889 | + | |
890 | +<!-- treemap(expenditure_gber,index= "all_objective_names_gber_only", "expenditure" --> | |
891 | +<!-- , title=paste("Top GBER Articles in ", year_focus, sep=""), --> | |
892 | +<!-- fontsize.title = 22,fontfamily.title =c("bold"), draw=T) --> | |
893 | +<!-- ``` --> | |
894 | + | |
895 | + | |
896 | + | |
897 | + | |
898 | + | |
899 | + | |
900 | +In terms of State aid instruments, `r ms3` privileged the use of | |
901 | +"`r expenditure_aid$harmonised_aid_instrument[1]`" (around | |
902 | +`r expenditure_aid$expenditure_print[1]`, | |
903 | +`r expenditure_aid$share2[1]`% of total State aid spending), | |
904 | +followed by | |
905 | +"`r expenditure_aid$harmonised_aid_instrument[2]`" | |
906 | +(`r expenditure_aid$expenditure_print[2]`, | |
907 | +`r expenditure_aid$share2[2]`% of total State aid spending), | |
908 | +and | |
909 | +"`r expenditure_aid$harmonised_aid_instrument[3]`" (around | |
910 | +`r expenditure_aid$expenditure_print[3]`, | |
911 | +`r expenditure_aid$share2[3]`% of total State aid spending). | |
912 | + | |
913 | +In Figure \@ref(fig:topinstruments) we illustrate the actual spending for the top | |
914 | +instruments in `r year_focus`. | |
915 | + | |
916 | +```{r topinstruments, fig.cap="State aid expenditure for the main instruments.", echo=FALSE,fig.height = 6, fig.width = 12} | |
917 | +ggplot(data = expenditure_aid_sel, | |
918 | + aes(x = expenditure, y=fct_rev(top_instrument))) + | |
919 | + geom_bar(position="dodge", stat="identity", alpha=1, color="black") + | |
920 | + ## geom_text(aes(label=share_label), position=position_dodge(width=0.9), | |
921 | + ## hjust=-.1, | |
922 | + ## vjust=-0.1, | |
923 | + ## size=5)+ | |
924 | + ## coord_cartesian(xlim = c(0, 1)) + | |
925 | + my_ggplot_theme2("top")+ | |
926 | + ## scale_x_continuous(labels = label_percent())+ | |
927 | + scale_y_discrete(labels = wrap_format(20))+ | |
928 | + xlab("State aid expenditure (million EUR)")+ | |
929 | + ylab(NULL)+ | |
930 | + labs(title=paste("Top State aid instruments in ", | |
931 | + year_focus, sep="")) | |
932 | +``` | |
933 | + | |
934 | + | |
935 | + | |
936 | +# State aid expenditure for COVID-19 measures | |
937 | + | |
938 | + In `r max(covid_years)` the Covid19-related expenditure for `r ms3` amounted to | |
939 | + `r output_covid |> filter(year==max(covid_years), | |
940 | + country!="EU27")|>pull(total_print)` i.e. | |
941 | + `r output_covid |> filter(year==max(covid_years), | |
942 | + country!="EU27")|>pull(percent)` | |
943 | + of the total State aid expenditure. In `r min(covid_years)` this | |
944 | + amounted to `r output_covid |> filter(year==min(covid_years), | |
945 | + country!="EU27")|>pull(total_print)`, i.e. `r output_covid |> filter(year==min(covid_years), | |
946 | + country!="EU27")|>pull(percent)` of the total. | |
947 | + We compare this figure to the | |
948 | + share of Covid19 State aid | |
949 | + expenditure at the EU27 level | |
950 | + (`r output_covid |> filter(year==max(covid_years), | |
951 | + country=="EU27")|>pull(percent)` in `r max(covid_years)` and `r output_covid |> filter(year==min(covid_years), | |
952 | + country=="EU27")|>pull(percent)` in `r min(covid_years)`). | |
953 | + In Figure \@ref(fig:covid19) we plot these values for ease of | |
954 | + comparison including also the data for `r covid_years[2]`. | |
955 | + | |
956 | + | |
957 | + | |
958 | +```{r covid19, fig.cap="Covid19 expenditure as a share of total State aid expenditure.", echo=FALSE,fig.height = 6, fig.width = 12} | |
959 | + | |
960 | +my_pal <- pal_npg("nrc")(3) | |
961 | + | |
962 | + | |
963 | +ggplot(data = output_covid, | |
964 | + aes(x = share, | |
965 | + y=country, fill=fct_rev(year))) + | |
966 | + geom_bar(position="dodge", stat="identity", alpha=1, color="black") + | |
967 | + geom_text(aes(label=percent), position=position_dodge(width=0.9), | |
968 | + hjust=-.1, | |
969 | + vjust=-0.1, | |
970 | + size=5)+ | |
971 | + scale_fill_manual(NULL, ## labels=c("Inward Stocks","Outward Stocks" ), | |
972 | + breaks=c(2020, 2021, 2022) ,values=my_pal)+ | |
973 | + coord_cartesian(xlim = c(0, 1)) + | |
974 | + my_ggplot_theme2("top")+ | |
975 | + scale_x_continuous(labels = label_percent())+ | |
976 | + scale_y_discrete(labels =c("EU27", ms3) )+ | |
977 | + xlab("Share of Covid19 State Aid Expenditure")+ | |
978 | + ylab(NULL) | |
979 | + | |
980 | +``` | |
981 | + | |
982 | + | |
983 | +# State aid expenditure for measures related to the Russian invasion of Ukraine | |
984 | + | |
985 | + In `r max(ukraine_years)` the expenditure to counterbalance the | |
986 | + negative effects of the Russian invasion of Ukraine, under the | |
987 | + Temporary Crisis Framework or based on its principles, for `r ms3` amounted to | |
988 | + `r output_ukraine |> filter(year==max(ukraine_years), | |
989 | + country!="EU27")|>pull(total_print)` i.e. | |
990 | + `r output_ukraine |> filter(year==max(ukraine_years), | |
991 | + country!="EU27")|>pull(percent)` | |
992 | + of the total State aid expenditure. | |
993 | + | |
994 | + We compare this figure to the | |
995 | + share of TCF-related State aid | |
996 | + expenditure at the EU27 level | |
997 | + `r output_ukraine |> filter(year==max(ukraine_years), | |
998 | + country=="EU27")|>pull(percent)` in `r max(ukraine_years)` in Figure \@ref(fig:tcf). | |
999 | + | |
1000 | + | |
1001 | +```{r tcf, fig.cap="TCF-related expenditure as a share of total State aid expenditure.", echo=FALSE,fig.height = 6, fig.width = 12} | |
1002 | + | |
1003 | +my_pal <- pal_npg("nrc")(3) | |
1004 | + | |
1005 | + | |
1006 | +ggplot(data = output_ukraine, | |
1007 | + aes(x = share, | |
1008 | + y=country, fill=fct_rev(year))) + | |
1009 | + geom_bar(position="dodge", stat="identity", alpha=1, color="black") + | |
1010 | + geom_text(aes(label=percent), position=position_dodge(width=0.9), | |
1011 | + hjust=-.1, | |
1012 | + vjust=-0.1, | |
1013 | + size=5)+ | |
1014 | + scale_fill_manual(NULL, ## labels=c("Inward Stocks","Outward Stocks" ), | |
1015 | + breaks=c(2020, 2021, 2022) ,values=my_pal)+ | |
1016 | + coord_cartesian(xlim = c(0, 1)) + | |
1017 | + my_ggplot_theme2("top")+ | |
1018 | + scale_x_continuous(labels = label_percent())+ | |
1019 | + scale_y_discrete(labels =c("EU27", ms3) )+ | |
1020 | + xlab("Share of TCF-related State aid expenditure")+ | |
1021 | + ylab(NULL) | |
1022 | + | |
1023 | +``` | |
1024 | + |