• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

修订版c89389ba836f90559b646d2ce8872adb3b3404b9 (tree)
时间2022-07-26 17:14:59
作者Lorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

Extra calculations added.

更改概述

差异

diff -r 1771386c36c8 -r c89389ba836f R-codes/quick_compliance.R
--- a/R-codes/quick_compliance.R Mon Jul 25 22:20:29 2022 +0200
+++ b/R-codes/quick_compliance.R Tue Jul 26 10:14:59 2022 +0200
@@ -15,7 +15,7 @@
1515 df_sc <- readRDS("/home/lorenzo/MEGA/work/COMP/scoreboard/scoreboard_2021/scoreboard.RDS")
1616
1717
18-df_tam <- readRDS("/home/lorenzo/MEGA/work/COMP/stat_support/publish_TAM/TAM_cleaned_for_shiny.RDS")
18+df_tam <- readRDS("TAM_cleaned_for_shiny.RDS")
1919
2020 df_sc_ms_no_covid <- df_sc |>
2121 filter(expenditure_year %in% year_sel,
@@ -261,6 +261,90 @@
261261
262262
263263
264-
265-
264+###############################################################################
265+###############################################################################
266+###############################################################################
267+###############################################################################
268+###############################################################################
269+###############################################################################
270+
271+
272+df_tam_cases <- df_tam |>
273+ filter(year %in% year_sel) |>
274+ group_by(beneficiary_country,case_reference, year, is_covid_case ) |>
275+ summarise(nominal_tam_mio_eur=sum(nominal_value_extended_eur, na.rm=T)/1e6,
276+ aid_tam_mio_eur=sum(granted_value_extended_eur, na.rm=T)/1e6) |>
277+ ungroup() |>
278+ mutate(aid_above_nominal_tam=if_else(aid_tam_mio_eur>nominal_tam_mio_eur, "yes", "no"))
279+
280+
281+
282+df_sc_cases <- df_sc |>
283+ filter(expenditure_year %in% year_sel) |>
284+ group_by(member_state_2_letter_codes, case_number, expenditure_year,
285+ covid) |>
286+ summarise(nominal_sc_mio_eur=sum(nominal_amount_eur, na.rm=T),
287+ aid_sc_mio_eur=sum(aid_element_eur, na.rm=T)) |>
288+ ungroup()
289+
290+
291+df_sc_tam_cases <- df_tam_cases |>
292+ inner_join(y=df_sc_cases, by=c("case_reference"="case_number",
293+ "year"="expenditure_year"))
294+
295+
296+
297+
298+##########################################################################
299+##########################################################################
300+##########################################################################
301+##########################################################################
302+
303+
304+equal_within <- function(x, y, percent){
305+
306+
307+ res <- if_else(near(abs(x-y)/abs(min(x,y)),percent/100.), T, F)
308+
309+ return(res)
310+
311+
312+}
313+
314+
315+ms_tam_covid <- df_tam |>
316+ filter(is_covid_case =="Yes",
317+ year %in% year_covid) |>
318+ group_by(beneficiary_country, year) |>
319+ summarise(nominal_expenditure_covid_tam=sum(nominal_value_extended_eur, na.rm=T)/1e6,
320+ nominal_expenditure_covid_tam_original=sum(nominal_aid_absolute_eur, na.rm=T )/1e6) |>
321+ ungroup()
322+
323+
324+ms_scoreboard_covid <- df_sc |>
325+ filter(covid ==T) |>
326+ group_by(member_state, expenditure_year) |>
327+ summarise(aggregated_aid_element_covid_scoreboard=sum(aid_element_eur, na.rm=T),
328+ nominal_expenditure_covid_scoreboard=sum(nominal_amount_eur, na.rm=T)) |>
329+ ungroup() |>
330+ filter(aggregated_aid_element_covid_scoreboard>0)
331+
332+jrc_agg <- read_csv("volumesCC.csv") |>
333+ clean_names()
334+
335+
336+jrc_agg_covid <- jrc_agg |>
337+ filter(covid_sari == 1) |>
338+ left_join(y=ms_scoreboard_covid, by=c("memberstate"="member_state")) |>
339+ left_join(y=ms_tam_covid, by=c("memberstate"="beneficiary_country")) |>
340+ select(-c(expenditure_year, year))
341+
342+
343+save_excel(jrc_agg_covid, "covid_test.xlsx")
344+
345+
346+
347+
348+
349+
266350 print("So far so good")