• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版121264f50667afc4b3b8d98d5ef6e5b00927c73c (tree)
时间2023-02-08 00:55:18
作者Lorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

I replaced most of the %>% with |>, but one is still missing.

更改概述

差异

diff -r bd17fd027114 -r 121264f50667 markdown/fiches_automatic.Rmd
--- a/markdown/fiches_automatic.Rmd Tue Feb 07 09:52:06 2023 +0100
+++ b/markdown/fiches_automatic.Rmd Tue Feb 07 16:55:18 2023 +0100
@@ -28,157 +28,11 @@
2828 source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R")
2929
3030
31-## iso_map <- tibble(iso3=c("AUT", "BEL", "BGR", "CYP", "CZE", "DEU", "DNK", "ESP", "EST", "FIN",
32-## "FRA",
33-## "GRC", "HRV", "HUN", "IRL", "ITA", "LTU", "LUX", "LVA", "MLT",
34-## "NLD", "POL", "PRT",
35-## "ROM", "SVK", "SVN", "SWE"),
36-## country=c("Austria", "Belgium", "Bulgaria", "Cyprus", "Czech Republic", "Germany",
37-## "Denmark", "Spain", "Estonia", "Finland", "France", "Greece",
38-## "Croatia", "Hungary", "Ireland","Italy", "Lituania", "Luxembourg",
39-## "Latvia", "Malta", "Netherlands", "Poland", "Portugal",
40-## "Romania", "Slovakia", "Slovenia", "Sweden")
41-## )
42-
43-## add_total <- function(x, pos=1, ...){
44-## adorn_totals(x, ...) %>% as_tibble %>%
45-## move_row(nrow(.), pos)
46-## }
47-
48-## add_total <- function(x, pos=1, ...){
49-## x <- as_tibble(x)
50-
51-## adorn_totals(x, ...) |>
52-## as_tibble() |>
53-## move_row(nrow(.), pos)
54-## }
55-
56-
57-## add_total <- function(x, pos=1, ...){
58-
59-
60-
61-## x |> as_tibble() |>
62-## adorn_totals( ...) |>
63-## as_tibble() |>
64-## (\(x) move_row(x, nrow(x)+1, pos))()
65-
66-## }
67-
68-
69-
70-## iso_map <- tibble(iso3=c("AUT", "BEL", "BGR", "CYP", "CZE", "DEU", "DNK", "ESP", "EST", "FIN",
71-## "FRA",
72-## "GRC", "HRV", "HUN", "IRL", "ITA", "LTU", "LUX", "LVA", "MLT",
73-## "NLD", "POL", "PRT",
74-## "ROM", "SVK", "SVN", "SWE", "GBR"),
75-## iso2 = c("AT", "BE", "BG", "CY", "CZ","DE",
76-## "DK", "ES" ,"EE", "FI", "FR", "EL", "HR", "HU", "IE",
77-## "IT" , "LT","LU", "LV", "MT", "NL", "PL",
78-## "PT", "RO", "SK", "SI", "SE", "UK"),
79-
80-## country=c("Austria", "Belgium", "Bulgaria", "Cyprus", "Czechia", "Germany",
81-## "Denmark", "Spain", "Estonia", "Finland", "France", "Greece",
82-## "Croatia", "Hungary", "Ireland","Italy", "Lithuania", "Luxembourg",
83-## "Latvia", "Malta", "Netherlands", "Poland", "Portugal",
84-## "Romania", "Slovakia", "Slovenia", "Sweden", "United Kingdom")
85-## )
86-
8731
8832
8933 # Suppress summarise info
9034 options(dplyr.summarise.inform = FALSE)
9135
92-## '%!in%' <- function(x,y)!('%in%'(x,y))
93-
94-
95-
96-## format_col <- function(x, n, my_sep=" "){
97-
98-## res <- format(round(x, n), nsmall = n, big.mark= my_sep, trim=TRUE )
99-
100-## return(res)
101-
102-## }
103-
104-
105-## recode_many <- function(x, old_names, new_names){
106-
107-## name_lookup <- set_names(new_names, old_names) %>% as.list
108-
109-## res <- recode(x, !!!name_lookup)
110-## return(res)
111-
112-## }
113-
114-
115-## my_ggplot_theme2 <- function(legend_coord){
116-## theme_bw()+
117-
118-## theme(## legend.title = element_text(vjust=1,lineheight=1, size=14 ),
119-
120-## legend.title = element_text(vjust = 1,lineheight=1,
121-## size=14, margin = margin(t = 4.5)),
122-## legend.spacing.y = grid::unit(3, "pt"),
123-## legend.text.align = 0.5,
124-
125-## panel.grid.minor = element_blank(),
126-## plot.title = element_text(lineheight=.8, size=24, face="bold",
127-## vjust=1),legend.text = element_text(vjust=.4,lineheight=1,size = 14 ),
128-## axis.title.x = element_text(size = 20, vjust=1),
129-## axis.title.y = element_text(size = 20, angle=90, vjust=1),
130-## axis.text.x = element_text(size=15, colour="black", vjust=1),
131-## axis.text.y = element_text(size=15, colour="black", hjust=1),
132-## legend.position = legend_coord,
133-## strip.background = element_rect(colour = 'blue',
134-## fill = 'white', size = 1, linetype=1),
135-## strip.text.x = element_text(colour = 'red', angle = 0,
136-## size = 12, hjust = 0.5,
137-## vjust = 0.5, face = 'bold'),
138-## strip.text.y = element_text(colour = 'red', angle = 0,
139-## size = 12, hjust = 0.5,
140-## vjust = 0.5, face = 'bold'),
141-
142-## )
143-## }
144-
145-
146-
147-
148-## round_preserve_sum <- function(x, digits = 0) {
149-## up <- 10^digits
150-## x <- x * up
151-## y <- floor(x)
152-## indices <- tail(order(x-y), round(sum(x, na.rm=T)) - sum(y, na.rm=T))
153-## y[indices] <- y[indices] + 1
154-## y / up
155-## }
156-
157-
158-## ##a function to move a row in a data frame.
159-
160-## move_row <- function(df, ini_pos, fin_pos){
161-
162-## ll <- nrow(df)
163-
164-## row_pick <- slice(df, ini_pos)
165-
166-## if (fin_pos=="last"){
167-
168-## res <- df %>%
169-## slice(-ini_pos) %>%
170-## add_row(row_pick, .before = ll)
171-
172-
173-## } else{
174-
175-## res <- df %>%
176-## slice(-ini_pos) %>%
177-## add_row(row_pick, .before = fin_pos)
178-## }
179-
180-## return(res)
181-## }
18236
18337 ############################################################################
18438 ############################################################################
@@ -190,10 +44,10 @@
19044
19145
19246
193-ms3 <- iso_map_eu28 %>%
194- filter(iso3==MS) %>%
195- pull(country) %>%
196- as.character
47+ms3 <- iso_map_eu28 |>
48+ filter(iso3==MS) |>
49+ pull(country) |>
50+ as.character()
19751
19852
19953 ## covid_qualifiers <- c( "Covid19-TF",
@@ -202,7 +56,7 @@
20256 ## )
20357
20458
205-scoreboard <- readRDS("../scoreboard.RDS") %>%
59+scoreboard <- readRDS("../scoreboard.RDS") |>
20660 filter(!is.na(aid_element_eur)) |>
20761 rename("year"="expenditure_year",
20862 "amount_spent_aid_element_in_eur_million" ="aid_element_eur",
@@ -213,24 +67,24 @@
21367 ## mutate(member_state=recode_many(member_state,iso_map$country,
21468 ## iso_map$iso3 ))
21569
216-scoreboard_ms <- scoreboard %>%
70+scoreboard_ms <- scoreboard |>
21771 filter(member_state_3_letter_codes==MS)
21872
219-year_focus <- scoreboard_ms %>%
220- pull(year) %>%
73+year_focus <- scoreboard_ms |>
74+ pull(year) |>
22175 max()
22276
22377
22478 ini_focus <- year_focus-10
22579
22680
227-cases <- scoreboard_ms %>%
81+cases <- scoreboard_ms |>
22882 filter(year==max(year),
22983 ## duration_end>=max(year),
23084 amount_spent_aid_element_in_eur_million>0
231- )%>%
85+ ) |>
23286 select(member_state_3_letter_codes,case_no, year,amount_spent_aid_element_in_eur_million,
233- procedure_name) %>%
87+ procedure_name) |>
23488 ## filter(grepl("SA.", case_no)) %>%
23589 distinct(case_no,.keep_all =T )
23690
@@ -238,24 +92,24 @@
23892
23993
24094
241-total_amount_eu27 <- scoreboard %>%
95+total_amount_eu27 <- scoreboard |>
24296 filter(year==max(year),
24397 ## duration_end>=max(year),
24498 amount_spent_aid_element_in_eur_million>0,
24599 member_state_3_letter_codes %in% iso_map_eu27$iso3
246- ) %>%
100+ ) |>
247101 summarise(total=sum(amount_spent_aid_element_in_eur_million))
248102
249103
250104
251-total_amount_eu27_covid <- scoreboard %>%
105+total_amount_eu27_covid <- scoreboard |>
252106 filter(year==max(year),
253107 ## all_intq %in% covid_qualifiers,
254108 covid==T,
255109 ## duration_end>=max(year),
256110 amount_spent_aid_element_in_eur_million>0,
257111 member_state_3_letter_codes %in% iso_map_eu27$iso3
258- ) %>%
112+ ) |>
259113 summarise(total=sum(amount_spent_aid_element_in_eur_million)) |>
260114 ungroup()
261115
@@ -272,7 +126,7 @@
272126 ungroup()
273127
274128
275-total_amount_MS_covid <- scoreboard %>%
129+total_amount_MS_covid <- scoreboard |>
276130 filter(year==max(year),
277131 member_state_3_letter_codes==MS,
278132 ## all_intq %in% covid_qualifiers,
@@ -280,38 +134,38 @@
280134 ## duration_end>=max(year),
281135 amount_spent_aid_element_in_eur_million>0,
282136 member_state_3_letter_codes %in% iso_map_eu27$iso3
283- ) %>%
137+ ) |>
284138 summarise(total=sum(amount_spent_aid_element_in_eur_million)) |>
285139 ungroup()
286140
287141
288-covid_summary <- total_amount_eu27 %>%
289- rename("total_eu"="total") %>%
142+covid_summary <- total_amount_eu27 |>
143+ rename("total_eu"="total") |>
290144 mutate(total_eu27_covid=total_amount_eu27_covid$total,
291145 total_ms=total_amount_MS$total,
292- total_ms_covid=total_amount_MS_covid$total) %>%
146+ total_ms_covid=total_amount_MS_covid$total) |>
293147 mutate(eu_covid_percentage=total_eu27_covid/total_eu,
294148 ms_covid_percentage=total_ms_covid/total_ms)
295149
296-covid_summary_long <- covid_summary %>%
297- select(contains("percentage")) %>%
150+covid_summary_long <- covid_summary |>
151+ select(contains("percentage")) |>
298152 pivot_longer(cols = c(eu_covid_percentage ,
299153 ms_covid_percentage
300- ) , names_to= "country", values_to="covid_percentage" ) %>%
301- mutate(ll=format_col(covid_percentage*100,1)) %>%
302- mutate(ll=paste(ll, "%", sep="")) %>%
303- arrange(country) %>%
154+ ) , names_to= "country", values_to="covid_percentage" ) |>
155+ mutate(ll=format_col(covid_percentage*100,1)) |>
156+ mutate(ll=paste(ll, "%", sep="")) |>
157+ arrange(country) |>
304158 mutate(country=fct_inorder(country))
305159
306160
307161
308162 n_cases <- nrow(cases)
309163
310-stat_cases <- cases %>%
311- tabyl(procedure_name) %>%
312- mutate(percent=round_preserve_sum(percent*100,1)) %>%
313- add_total() %>%
314- mutate(percent=format_col(percent,1)) %>%
164+stat_cases <- cases |>
165+ tabyl(procedure_name) |>
166+ mutate(percent=round_preserve_sum(percent*100,1)) |>
167+ add_total() |>
168+ mutate(percent=format_col(percent,1)) |>
315169 mutate(percent=paste(percent, "%", sep=""))
316170
317171
@@ -326,38 +180,38 @@
326180
327181
328182
329-old_cases <- scoreboard %>%
183+old_cases <- scoreboard |>
330184 filter(year>=ini_focus, year!= year_focus, member_state_3_letter_codes==MS)
331185
332186 new_cases_list <- setdiff(cases$case_no, old_cases$case_no)
333187
334-cases_new <- scoreboard_ms %>%
188+cases_new <- scoreboard_ms |>
335189 filter(case_no %in% new_cases_list ,
336190 ## duration_end>=max(year),
337191 amount_spent_aid_element_in_eur_million>0
338- )%>%
192+ ) |>
339193 select(member_state_3_letter_codes,case_no, year,amount_spent_aid_element_in_eur_million,
340- procedure_name) %>%
194+ procedure_name) |>
341195 ## filter(grepl("SA.", case_no)) %>%
342196 distinct(case_no,.keep_all =T )
343197
344-stat_cases_new <- cases_new %>%
345- tabyl(procedure_name) %>%
198+stat_cases_new <- cases_new |>
199+ tabyl(procedure_name) |>
346200 mutate(percent=round(percent*100,1))
347201
348202
349203 if (nrow(stat_cases_new)==0){
350- stat_cases_new <- stat_cases_new %>%
204+ stat_cases_new <- stat_cases_new |>
351205 add_row(percent=0)
352206
353207
354208 }
355209
356-stat_cases2 <- scoreboard %>%
357- filter(year>=ini_focus, member_state_3_letter_codes==MS) %>%
358- group_by(year, procedure_name) %>%
359- summarise(expenditure=sum(amount_spent_aid_element_in_eur_million/1e3)) %>%
360- ungroup
210+stat_cases2 <- scoreboard |>
211+ filter(year>=ini_focus, member_state_3_letter_codes==MS) |>
212+ group_by(year, procedure_name) |>
213+ summarise(expenditure=sum(amount_spent_aid_element_in_eur_million/1e3)) |>
214+ ungroup()
361215
362216
363217 ## stat_cases3 <- scoreboard %>%
@@ -375,69 +229,84 @@
375229 ## mutate(percent=paste(percent, "%", sep=""))
376230
377231
378-stat_cases3 <- scoreboard %>%
379- filter(year>=ini_focus, member_state_3_letter_codes==MS) %>%
232+stat_cases3 <- scoreboard |>
233+ filter(year>=ini_focus, member_state_3_letter_codes==MS) |>
380234 ## mutate(procedure2=if_else(procedure_name=="General Block Exemption Regulation", "(G)BER", procedure_name)) %>%
381- group_by( procedure_name) %>%
382- summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)/1e3) %>%
383- ungroup %>%
384- mutate(expenditure=round_preserve_sum(expenditure, 1)) %>%
385- mutate(percent=expenditure/sum(expenditure)*100) %>%
386- mutate(percent=round_preserve_sum(percent,1)) %>%
387- add_total() %>%
235+ group_by( procedure_name) |>
236+ summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)/1e3) |>
237+ ungroup() |>
238+ mutate(expenditure=round_preserve_sum(expenditure, 1)) |>
239+ mutate(percent=expenditure/sum(expenditure)*100) |>
240+ mutate(percent=round_preserve_sum(percent,1)) |>
241+ add_total() |>
388242 mutate(percent=format_col(percent,1),
389- expenditure=format_col(expenditure,1)) %>%
390- mutate(percent=paste(percent,"%", sep="")) %>%
243+ expenditure=format_col(expenditure,1)) |>
244+ mutate(percent=paste(percent,"%", sep="")) |>
391245 mutate(expenditure=if_else(expenditure!="0.0", expenditure,"less than 0.1"),
392246 percent=if_else(percent!="0.0%", percent, "less than 0.1%"))
393247
394248
395249
396250
397-top5 <- cases %>%
398- group_by(case_no) %>%
251+## top5 <- cases %>%
252+## group_by(case_no) %>%
253+## summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) %>%
254+## ungroup %>%
255+## arrange(desc(expenditure)) %>%
256+## mutate(share=expenditure/sum(expenditure)) %>%
257+## slice(1:5) %>%
258+## mutate(cum_share=cumsum(share),
259+## cum_expenditure=cumsum(expenditure)) %>%
260+## filter(expenditure>0)
261+
262+
263+top5 <- scoreboard_ms |>
264+ filter(year==max(year)) |>
265+ group_by(case_no) |>
399266 summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) %>%
400- ungroup %>%
401- arrange(desc(expenditure)) %>%
402- mutate(share=expenditure/sum(expenditure)) %>%
403- slice(1:5) %>%
267+ ungroup() |>
268+ arrange(desc(expenditure)) |>
269+ mutate(share=expenditure/sum(expenditure)) |>
270+ slice(1:5) |>
404271 mutate(cum_share=cumsum(share),
405- cum_expenditure=cumsum(expenditure)) %>%
272+ cum_expenditure=cumsum(expenditure)) |>
406273 filter(expenditure>0)
407274
408275
409-top5_share <- top5 %>%
410- pull(cum_share) %>%
411- max() %>%
412- "*"(100) %>%
276+
277+
278+top5_share <- top5 |>
279+ pull(cum_share) |>
280+ max() |>
281+ multiply_by(100) |>
413282 round(1)
414283
415284
416-top5_expenditure <- top5 %>%
417- pull(cum_expenditure) %>%
285+top5_expenditure <- top5 |>
286+ pull(cum_expenditure) |>
418287 max()
419288
420289
421290
422291
423-total_expenditure <- scoreboard_ms %>%
424- filter(year>=ini_focus) %>%
425- pull(amount_spent_aid_element_in_eur_million) %>%
426- sum(na.rm=T) %>% "/"(1e3) %>%
292+total_expenditure <- scoreboard_ms |>
293+ filter(year>=ini_focus) |>
294+ pull(amount_spent_aid_element_in_eur_million) |>
295+ sum(na.rm=T) |> divide_by(1e3) |>
427296 round(1)
428297
429-total_expenditure_last <- scoreboard_ms %>%
430- filter(year==year_focus) %>%
431- pull(amount_spent_aid_element_in_eur_million) %>%
432- sum(na.rm=T) %>% "/"(1e3) %>%
298+total_expenditure_last <- scoreboard_ms |>
299+ filter(year==year_focus) |>
300+ pull(amount_spent_aid_element_in_eur_million) |>
301+ sum(na.rm=T) |> divide_by(1e3) |>
433302 round(2)
434303
435304
436-cofinancing <- scoreboard_ms %>%
305+cofinancing <- scoreboard_ms |>
437306 filter( year==max(year),
438307 ## duration_end>=max(year),
439308 amount_spent_aid_element_in_eur_million>0
440- ) %>%
309+ ) |>
441310 mutate(expenditure=amount_spent_aid_element_in_eur_million*
442311 co_financed)
443312
@@ -445,9 +314,9 @@
445314
446315
447316
448-cofinancing_expenditure <- cofinancing %>%
449- pull(expenditure) %>%
450- sum %>%
317+cofinancing_expenditure <- cofinancing |>
318+ pull(expenditure) |>
319+ sum() |>
451320 round(0)
452321
453322
@@ -455,67 +324,67 @@
455324 *100,1)
456325
457326
458-cofinancing_objective <- cofinancing %>%
459- group_by(scoreboard_objective) %>%
460- summarise(expenditure_objective=sum(expenditure)) %>%
461- ungroup %>%
462- arrange(desc(expenditure_objective)) %>%
463- mutate(share=expenditure_objective/sum(expenditure_objective)*100) %>%
327+cofinancing_objective <- cofinancing |>
328+ group_by(scoreboard_objective) |>
329+ summarise(expenditure_objective=sum(expenditure)) |>
330+ ungroup() |>
331+ arrange(desc(expenditure_objective)) |>
332+ mutate(share=expenditure_objective/sum(expenditure_objective)*100) |>
464333 mutate(share=round_preserve_sum(share,1))
465334
466335
467336
468337
469-expenditure_by_objective <- scoreboard_ms %>%
338+expenditure_by_objective <- scoreboard_ms |>
470339 filter(year==max(year),
471340 ## duration_end>=max(year),
472341 amount_spent_aid_element_in_eur_million>0
473- )%>%
342+ ) |>
474343 mutate(scoreboard_objective=recode(scoreboard_objective,
475- "Other"="Other policy objectives" )) %>%
476- group_by(scoreboard_objective) %>%
477- summarise(expenditure_objective=sum(amount_spent_aid_element_in_eur_million)) %>%
478- ungroup %>%
479- arrange(desc(expenditure_objective)) %>%
480- mutate(objectives_reduced=if_else(scoreboard_objective %in% scoreboard_objective[1:4], scoreboard_objective, "Other policy objectives" )) %>%
481- group_by(objectives_reduced) %>%
482- summarise(expenditure2=sum(expenditure_objective)) %>%
483- ungroup %>%
484- arrange(desc(expenditure2)) %>%
485- mutate(share=expenditure2/sum(expenditure2)) %>%
486- mutate(share2=round_preserve_sum(share*100,1)) %>%
487- mutate(share_label=paste(as.character(share2), "%", sep="")) %>%
488- move_row(which(.$objectives_reduced=="Other policy objectives"), nrow(.)) %>%
344+ "Other"="Other policy objectives" )) |>
345+ group_by(scoreboard_objective) |>
346+ summarise(expenditure_objective=sum(amount_spent_aid_element_in_eur_million)) |>
347+ ungroup() |>
348+ arrange(desc(expenditure_objective)) |>
349+ mutate(objectives_reduced=if_else(scoreboard_objective %in% scoreboard_objective[1:4], scoreboard_objective, "Other policy objectives" )) |>
350+ group_by(objectives_reduced) |>
351+ summarise(expenditure2=sum(expenditure_objective)) |>
352+ ungroup() |>
353+ arrange(desc(expenditure2)) |>
354+ mutate(share=expenditure2/sum(expenditure2)) |>
355+ mutate(share2=round_preserve_sum(share*100,1)) |>
356+ mutate(share_label=paste(as.character(share2), "%", sep="")) %>%
357+ move_row(which(.$objectives_reduced=="Other policy objectives"), nrow(.)) |>
489358 ## mutate(objectives_reduced=wrapper1(objectives_reduced, 25)) %>%
490- mutate(objectives_reduced=factor(objectives_reduced)) %>%
359+ mutate(objectives_reduced=factor(objectives_reduced)) |>
491360 mutate(objectives_reduced=fct_inorder(objectives_reduced))
492361
493-expenditure_gber <- scoreboard_ms %>%
362+expenditure_gber <- scoreboard_ms |>
494363 filter(year==max(year),
495364 ## duration_end>=max(year),
496365 amount_spent_aid_element_in_eur_million>0
497- )%>%
498- filter(!is.na(all_objective_names_gber_only)) %>%
499- group_by(all_objective_names_gber_only) %>%
500- summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) %>%
501- ungroup %>%
502- arrange(desc(expenditure)) %>%
503- mutate(share=expenditure/sum(expenditure)) %>%
366+ ) |>
367+ filter(!is.na(all_objective_names_gber_only)) |>
368+ group_by(all_objective_names_gber_only) |>
369+ summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) |>
370+ ungroup() |>
371+ arrange(desc(expenditure)) |>
372+ mutate(share=expenditure/sum(expenditure)) |>
504373 mutate(share2=round_preserve_sum(share*100,1))
505374
506375
507-expenditure_aid <- scoreboard_ms %>%
376+expenditure_aid <- scoreboard_ms |>
508377 filter(year==max(year),
509378 ## duration_end>=max(year),
510379 amount_spent_aid_element_in_eur_million>0
511- )%>%
512- filter(!is.na(harmonised_aid_instrument)) %>%
513- group_by(harmonised_aid_instrument) %>%
514- summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) %>%
515- ungroup %>%
516- arrange(desc(expenditure)) %>%
517- mutate(share=expenditure/sum(expenditure)) %>%
518- mutate(share2=round_preserve_sum(share*100,1)) %>%
380+ ) |>
381+ filter(!is.na(harmonised_aid_instrument)) |>
382+ group_by(harmonised_aid_instrument) |>
383+ summarise(expenditure=sum(amount_spent_aid_element_in_eur_million)) |>
384+ ungroup() |>
385+ arrange(desc(expenditure)) |>
386+ mutate(share=expenditure/sum(expenditure)) |>
387+ mutate(share2=round_preserve_sum(share*100,1)) |>
519388 mutate(expenditure2=round(expenditure,0))
520389
521390 ```