修订版 | 439429466c2c3e20b225add08fabf83079083e55 (tree) |
---|---|
时间 | 2024-12-02 19:00:38 |
作者 | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I merged some heads
@@ -0,0 +1,71 @@ | ||
1 | +rm(list=ls()) | |
2 | + | |
3 | +library(tidyverse) | |
4 | +library(janitor) | |
5 | +library(openxlsx) | |
6 | +## library(stringr) | |
7 | + | |
8 | +source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R") | |
9 | + | |
10 | + | |
11 | +df_ec <- read_csv("../input/SA-Case_Full_Extract_Case_EC_2024-11-1511-06-55.csv.gz") |> | |
12 | + clean_names() | |
13 | + | |
14 | +## keep only the cases for which a decision has been taken | |
15 | + | |
16 | +df_filtered <- df_ec |> | |
17 | + filter(decision_type_article %in% c("Article 4(3) - decision not to raise objections", "Article 7(3) - positive decision" ), | |
18 | + member_state_long_name!="United Kingdom") |> | |
19 | + mutate(new_objective=paste(primary_objective, secondary_objective, sep=" ")) | |
20 | + | |
21 | + | |
22 | +## first chunk: remedy for a serious disturbance in the economy as | |
23 | +## objective, but do not consider the cases related to the TCF, TCTF and Covid | |
24 | + | |
25 | +sa <- "SA.100264" | |
26 | + | |
27 | + | |
28 | +df_filtered_condition1 <- df_filtered |> | |
29 | + filter(str_detect(new_objective, "Remedy for a serious disturbance in the economy")) |> | |
30 | + filter(internal_qualifier_s %!in% c("Temporary Crisis and Transition Framework (TCTF)","Temporary Crisis Framework (TCF)" , "Covid19-TF" )) | |
31 | + | |
32 | +t1 <- df_filtered_condition1 |> | |
33 | + filter(case_reference == sa) | |
34 | + | |
35 | + | |
36 | +##second chunk: keep cases where the internal qualifier is the financial | |
37 | +## crisis case. | |
38 | + | |
39 | +df_filtered_condition2 <- df_filtered |> | |
40 | + filter(internal_qualifier_s %in% "Financial crisis case" ) | |
41 | + | |
42 | +t2 <- df_filtered_condition2 |> | |
43 | + filter(case_reference == sa) | |
44 | + | |
45 | + | |
46 | +## third chunk: keep the bit about the temporart framework | |
47 | + | |
48 | +df_filtered_condition3 <- df_filtered |> | |
49 | + filter(str_detect(internal_qualifier_s,"Temporary Framework" )) | |
50 | + | |
51 | +t3 <- df_filtered_condition3 |> | |
52 | + filter(case_reference == sa) | |
53 | + | |
54 | + | |
55 | + | |
56 | +df_out <- bind_rows(df_filtered_condition1, | |
57 | + df_filtered_condition2, | |
58 | + df_filtered_condition3) |> | |
59 | + filter(!is.na(internal_qualifier_s)) | |
60 | + | |
61 | + | |
62 | +df_out_simple <- df_out |> | |
63 | + select(case_reference, internal_qualifier_s,case_title,member_state_long_name, new_objective, case_title ) |> | |
64 | + distinct() |> | |
65 | + arrange(case_reference) | |
66 | + | |
67 | + | |
68 | +save_excel(df_out_simple, "../output/cases_to_filter.xlsx") | |
69 | + | |
70 | + | |
71 | +print("So far so good") |