Revisión | e946b59fa3b62251c486fe1185eb50a34c80cdcf (tree) |
---|---|
Tiempo | 2023-05-05 19:27:18 |
Autor | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I now use also another file for the used and approuved aid.
@@ -423,6 +423,48 @@ | ||
423 | 423 | "GEO"="iso2") |
424 | 424 | |
425 | 425 | |
426 | + | |
427 | +## df_gber_objective_up <- df %>% | |
428 | +## ## filter(!is.na(all_objective_names_gber_only)) %>% | |
429 | + | |
430 | +## mutate(amount_spent_aid_element_in_eur_million=if_else(!is.na(all_objective_names_gber_only),amount_spent_aid_element_in_eur_million, 0 )) %>% | |
431 | + | |
432 | +## mutate(aid_element_as_percent_national_gdp=if_else(!is.na(all_objective_names_gber_only),aid_element_as_percent_national_gdp, 0 )) %>% | |
433 | + | |
434 | +## mutate(aid_element_eur_adj=if_else(!is.na(all_objective_names_gber_only),aid_element_eur_adj, 0 )) %>% | |
435 | + | |
436 | +## mutate(all_objective_names_gber_only= | |
437 | +## recode(all_objective_names_gber_only, | |
438 | +## "Transport costs of goods in eligible areas (Art. 15(2))"= "Transport costs of goods in eligible areas (Art. 15(2)(a))" | |
439 | +## )) %>% | |
440 | +## group_by(year, iso2, all_objective_names_gber_only) %>% | |
441 | +## summarise(value=sum(amount_spent_aid_element_in_eur_million, na.rm=T), | |
442 | +## pc_gdp=sum(aid_element_as_percent_national_gdp, na.rm=T), | |
443 | +## value_adj=sum(aid_element_eur_adj, na.rm=T) | |
444 | +## ) %>% | |
445 | +## ungroup %>% | |
446 | +## ## left_join(y=gdp, by=c("year"="time_period", | |
447 | +## ## "iso2"="geo")) %>% | |
448 | +## ## mutate(pc_gdp=value/obs_value*100) %>% | |
449 | +## group_by(year, iso2) %>% | |
450 | +## mutate(value=round_preserve_sum(value,2), | |
451 | +## pc_gdp=round_preserve_sum(pc_gdp,2), | |
452 | +## value_adj=round_preserve_sum(value_adj,2)) %>% | |
453 | +## group_modify(~ .x %>% | |
454 | +## adorn_totals("row", fill="Total")) %>% | |
455 | +## ungroup %>% | |
456 | +## ## select(-obs_value) %>% | |
457 | +## mutate(DATAFLOW="COMP:AID_SCB_TYPE(1.0)", | |
458 | +## FREQ="A") %>% | |
459 | +## rename("MIO_EUR"="value", | |
460 | +## "PC_GDP"="pc_gdp", | |
461 | +## "MIO_EUR_ADJ"="value_adj") %>% | |
462 | +## pivot_longer(cols=c(PC_GDP, MIO_EUR, MIO_EUR_ADJ), names_to="UNIT", | |
463 | +## values_to="OBS_VALUE") %>% | |
464 | +## rename("TIME_PERIOD"="year", | |
465 | +## "GEO"="iso2") | |
466 | + | |
467 | + | |
426 | 468 | ## objectives_gber <- read_csv("CL_OBJ_GBER+COMP+1.0.csv") %>% |
427 | 469 | ## clean_data() |
428 | 470 |
@@ -947,7 +989,30 @@ | ||
947 | 989 | INST_FI,TIME_PERIOD, OBS_VALUE) |
948 | 990 | |
949 | 991 | |
950 | - used_13 <- bind_rows(used1, used2, used3) |> | |
992 | + | |
993 | +used4 <- read_csv("other_used2.csv") %>% | |
994 | + rename("country"="Member State") %>% | |
995 | + mutate(country=recode(country, "Czech Republic"="Czechia")) %>% | |
996 | + mutate(UNIT="MIO_EUR", FREQ="A") %>% | |
997 | + pivot_longer(cols=starts_with("2"), | |
998 | + names_to="TIME_PERIOD", | |
999 | + values_to="OBS_VALUE") %>% | |
1000 | + mutate(TIME_PERIOD=as.numeric(TIME_PERIOD), | |
1001 | + OBS_VALUE=as.numeric(OBS_VALUE)) %>% | |
1002 | + na_num_to_pattern(0) %>% | |
1003 | + mutate(INST_FI="INST4") %>% | |
1004 | + left_join(y=iso_map_eu28, by="country") %>% | |
1005 | + rename("GEO"="iso2") %>% | |
1006 | + mutate(DATAFLOW="COMP:AID_FI_USED(1.0)") %>% | |
1007 | + complete(GEO, UNIT, INST_FI, | |
1008 | + DATAFLOW, FREQ, TIME_PERIOD, fill=list(OBS_VALUE=0)) %>% | |
1009 | + select(DATAFLOW, FREQ, GEO,UNIT, | |
1010 | + INST_FI,TIME_PERIOD, OBS_VALUE) | |
1011 | + | |
1012 | + | |
1013 | + | |
1014 | + | |
1015 | + used_13 <- bind_rows(used1, used2, used3, used4) |> | |
951 | 1016 | filter(GEO!="UK") ## this year I remove the UK |
952 | 1017 | |
953 | 1018 | used_total <- used_13 %>% |
@@ -973,7 +1038,8 @@ | ||
973 | 1038 | |
974 | 1039 | |
975 | 1040 | df_used_finance_fin_save <- df_used_finance_fin%>% |
976 | - mutate(OBS_VALUE=format_col(OBS_VALUE,2,"")) | |
1041 | + mutate(OBS_VALUE=format_col(OBS_VALUE,2,"")) |> | |
1042 | + filter(GEO!="UK") | |
977 | 1043 | |
978 | 1044 | write_csv(df_used_finance_fin_save, "./finance_used/aid_fi_used+COMP+3.0.sdmx.csv") |
979 | 1045 | write_tsv(df_used_finance_fin_save, "./finance_used/aid_fi_used+COMP+3.0.sdmx.tsv") |
@@ -1049,7 +1115,31 @@ | ||
1049 | 1115 | INST_FI,TIME_PERIOD, OBS_VALUE) |
1050 | 1116 | |
1051 | 1117 | |
1052 | -used_13 <- bind_rows(used1, used2, used3) | |
1118 | + | |
1119 | +used4 <- read_csv("other_approuved2.csv") %>% | |
1120 | + rename("country"="Member State") %>% | |
1121 | + mutate(country=recode(country, "Czech Republic"="Czechia")) %>% | |
1122 | + mutate(UNIT="MIO_EUR", FREQ="A") %>% | |
1123 | + pivot_longer(cols=starts_with("2"), | |
1124 | + names_to="TIME_PERIOD", | |
1125 | + values_to="OBS_VALUE") %>% | |
1126 | + mutate(TIME_PERIOD=as.numeric(TIME_PERIOD), | |
1127 | + OBS_VALUE=as.numeric(OBS_VALUE)) %>% | |
1128 | + na_num_to_pattern(0) %>% | |
1129 | + mutate(INST_FI="INST4") %>% | |
1130 | + left_join(y=iso_map_eu28, by="country") %>% | |
1131 | + rename("GEO"="iso2") %>% | |
1132 | + mutate(DATAFLOW="COMP:AID_FI_APPROVED(1.0)") %>% | |
1133 | + complete(GEO, UNIT, INST_FI, | |
1134 | + DATAFLOW, FREQ, TIME_PERIOD, fill=list(OBS_VALUE=0)) %>% | |
1135 | + select(DATAFLOW, FREQ, GEO,UNIT, | |
1136 | + INST_FI,TIME_PERIOD, OBS_VALUE) | |
1137 | + | |
1138 | + | |
1139 | + | |
1140 | + | |
1141 | + | |
1142 | +used_13 <- bind_rows(used1, used2, used3, used4) | |
1053 | 1143 | |
1054 | 1144 | used_total <- used_13 %>% |
1055 | 1145 | group_by(DATAFLOW, FREQ, GEO, UNIT, TIME_PERIOD ) %>% |
@@ -1075,7 +1165,8 @@ | ||
1075 | 1165 | |
1076 | 1166 | |
1077 | 1167 | df_approved_finance_fin_save <- df_approved_finance_fin %>% |
1078 | - mutate(OBS_VALUE=format_col(OBS_VALUE,2,"")) | |
1168 | + mutate(OBS_VALUE=format_col(OBS_VALUE,2,"")) |> | |
1169 | + filter(GEO!="UK") | |
1079 | 1170 | |
1080 | 1171 | |
1081 | 1172 | write_csv(df_approved_finance_fin_save, "./finance_approuved/aid_fi_approved+COMP+3.0.sdmx.csv") |