Revision | 4dc967d20ad3a260b8a1eadf3b796ea535690b80 (tree) |
---|---|
Time | 2022-06-16 23:31:40 |
Author | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I added another data cube.
@@ -1180,9 +1180,6 @@ | ||
1180 | 1180 | write_tsv(df_approved_finance_fin_save, "aid_fi_approved+COMP+2.1.sdmx.tsv") |
1181 | 1181 | |
1182 | 1182 | |
1183 | -print("Done up to here!") | |
1184 | - | |
1185 | - | |
1186 | 1183 | ##################################################################### |
1187 | 1184 | ##################################################################### |
1188 | 1185 | ##################################################################### |
@@ -1226,6 +1223,81 @@ | ||
1226 | 1223 | summarise(total_obs=sum(OBS_VALUE), |
1227 | 1224 | total_gdp=sum(GDP_mio_eur)) |
1228 | 1225 | |
1226 | +#########################################################################à | |
1227 | +#########################################################################à | |
1228 | +#########################################################################à | |
1229 | +#########################################################################à | |
1230 | + | |
1231 | +df_notified <- df_ini %>% | |
1232 | + filter(case_type=="Notified Aid") %>% | |
1233 | + group_by(member_state_2_letter_codes, expenditure_year, scoreboard_objective) %>% | |
1234 | + summarise(aid_gdp=sum(aid_element_as_percent_national_gdp, na.rm=T), | |
1235 | + aid_mio_eur=sum(aid_element_eur_bn, na.rm=T)*1e3) %>% | |
1236 | + ungroup %>% | |
1237 | + group_by(member_state_2_letter_codes, expenditure_year) %>% | |
1238 | + group_modify(~ .x %>% | |
1239 | + adorn_totals("row", fill="Total")) %>% | |
1240 | + ungroup | |
1241 | + | |
1242 | + | |
1243 | + | |
1244 | + | |
1245 | +objectives_revised_notified <- df_notified %>% | |
1246 | + select(scoreboard_objective) %>% | |
1247 | + distinct %>% | |
1248 | + add_row(scoreboard_objective="Total") %>% | |
1249 | + move_row(which(.$scoreboard_objective=="Other"), nrow(.)) | |
1250 | + | |
1251 | + | |
1252 | +nn <- nrow(objectives_revised_notified)-2 | |
1253 | + | |
1254 | +nn_seq <- seq(nn) | |
1255 | + | |
1256 | + | |
1257 | + | |
1258 | +ll <- add_name_format_number("OBJ", nn_seq, 2, "") | |
1259 | + | |
1260 | +objectives_revised_notified <-objectives_revised_notified %>% | |
1261 | + mutate(CODE=c(ll, "TOTAL", "OTH")) %>% | |
1262 | + rename("NAME_en"="scoreboard_objective") %>% | |
1263 | + select(CODE, NAME_en) | |
1264 | + | |
1265 | + | |
1266 | + | |
1267 | +df_notified_fin_save <- df_notified %>% | |
1268 | + mutate(scoreboard_objective=recode_many(scoreboard_objective, | |
1269 | + objectives_revised_notified$NAME_en, | |
1270 | + objectives_revised_notified$CODE | |
1271 | + )) %>% | |
1272 | + pivot_longer(cols=c(aid_gdp, aid_mio_eur)) %>% | |
1273 | + mutate(DATAFLOW="COMP:AID_NOTI(1.0)", | |
1274 | + FREQ="A") %>% | |
1275 | + rename("GEO"="member_state_2_letter_codes", | |
1276 | + "TIME_PERIOD"="expenditure_year", | |
1277 | + "UNIT"="name", | |
1278 | + "OBS_VALUE"="value", | |
1279 | + "OBJECTIV_SCB"="scoreboard_objective") %>% | |
1280 | + mutate(UNIT=recode(UNIT,"aid_mio_eur"="MIO_EUR", | |
1281 | + "aid_gdp"="PC_GDP")) %>% | |
1282 | + select("DATAFLOW", | |
1283 | + "FREQ", | |
1284 | + "GEO", | |
1285 | + "UNIT", | |
1286 | + "OBJECTIV_SCB", | |
1287 | + "TIME_PERIOD", | |
1288 | + "OBS_VALUE") | |
1289 | + | |
1290 | + | |
1291 | +write_csv(df_notified_fin_save, "aid_scb_obj_notified+COMP+2.1.sdmx.csv") | |
1292 | +write_tsv(df_notified_fin_save, "aid_scb_obj_notified+COMP+2.1.sdmx.tsv") | |
1293 | + | |
1294 | + | |
1295 | + | |
1296 | +write_csv(objectives_revised_notified,"CL_OBJ_SCB_NOTIFIED+COMP+2.1.csv") | |
1297 | +write_tsv(objectives_revised_notified,"CL_OBJ_SCB_NOTIFIED+COMP+2.1.tsv") | |
1298 | + | |
1299 | + | |
1300 | + | |
1229 | 1301 | |
1230 | 1302 | |
1231 | 1303 |