Revision | 7ad70b93c0eb3ab7b535f564e08518313d4eaa1a (tree) |
---|---|
Time | 2023-05-05 19:28:32 |
Author | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I merged some heads.
@@ -6,7 +6,7 @@ | ||
6 | 6 | library(stringr) |
7 | 7 | library(lubridate) |
8 | 8 | library(RJSDMX) |
9 | -library(haven) | |
9 | +## library(haven) | |
10 | 10 | library(arrow) |
11 | 11 | |
12 | 12 |
@@ -17,14 +17,20 @@ | ||
17 | 17 | |
18 | 18 | read_estat <- 0 |
19 | 19 | |
20 | -df_ini1 <- read_csv("State_aid_in_Poland-2018-2019_above_500K_euro,_2020_above_100K_euro.csv" ## , locale = readr::locale(encoding = "latin1") | |
21 | - ) |> | |
22 | - clean_names() | |
20 | +## df_ini1 <- read_csv("State_aid_in_Poland-2018-2019_above_500K_euro,_2020_above_100K_euro.csv" ## , locale = readr::locale(encoding = "latin1") | |
21 | +## ) |> | |
22 | +## clean_names() | |
23 | 23 | |
24 | -df_ini2 <- read_csv("2021-data/State_aid_in_Poland-2021_above_100K_euro.csv") |> | |
25 | - clean_names() | |
24 | +## df_ini2 <- read_csv("2021-data/State_aid_in_Poland-2021_above_100K_euro.csv") |> | |
25 | +## clean_names() | |
26 | 26 | |
27 | -df_ini <- bind_rows(df_ini1, df_ini2) | |
27 | +## df_ini <- bind_rows(df_ini1, df_ini2) | |
28 | + | |
29 | + | |
30 | +df_ini <- read_csv("all-PL.csv", locale = readr::locale(encoding = "UTF-8" ## "latin1" | |
31 | + )) | |
32 | + | |
33 | +## df_ini <- readRDS("all-PL.RDS") | |
28 | 34 | |
29 | 35 | query <- "ert_bil_eur_a/A.AVG.NAC.PLN" |
30 | 36 |
@@ -112,6 +118,8 @@ | ||
112 | 118 | select(all_of(column_selection)) |> |
113 | 119 | rename_many( new_columns## [1:14] |
114 | 120 | , column_selection) |> |
121 | + mutate(aid_award_created_date=parse_date_time(aid_award_created_date,c("dmy", "ymd"))) |> | |
122 | + mutate(aid_award_granted_date=parse_date_time(aid_award_granted_date, c("dmy", "ymd"))) |> | |
115 | 123 | mutate(year=year(aid_award_granted_date ), |
116 | 124 | beneficiary_country="Poland") |> |
117 | 125 | left_join(y=all_rates_ini, by=c("year"="time_period")) |> |
@@ -134,37 +142,41 @@ | ||
134 | 142 | |
135 | 143 | |
136 | 144 | |
137 | -aid_instr_new <- c( | |
138 | -"Interest subsidy", | |
139 | -"Direct grant/ Interest rate subsidy", | |
140 | -"Guarantee", | |
141 | -"Other", | |
142 | -"Soft loan", | |
143 | -"Other forms of tax advantage", | |
144 | -"Other forms of tax advantage", | |
145 | -"Other", | |
146 | -"Other", | |
147 | -"Other forms of tax advantage", | |
148 | -"Loan/ Repayable advances", | |
149 | -"Loan/ Repayable advances", | |
150 | -"Direct grant/ Interest rate subsidy", | |
151 | -"Other", | |
152 | -"Other forms of tax advantage", | |
153 | -"Other forms of tax advantage", | |
154 | -"Soft loan", | |
155 | -"Provision of risk capital", | |
156 | -"Repayable advances", | |
157 | -"Other", | |
158 | -"Direct grant", | |
159 | -"Tax advantage or tax exemption" | |
160 | -) | |
145 | +## aid_instr_new <- c( | |
146 | +## "Interest subsidy", | |
147 | +## "Direct grant/ Interest rate subsidy", | |
148 | +## "Guarantee", | |
149 | +## "Other", | |
150 | +## "Soft loan", | |
151 | +## "Other forms of tax advantage", | |
152 | +## "Other forms of tax advantage", | |
153 | +## "Other", | |
154 | +## "Other", | |
155 | +## "Other forms of tax advantage", | |
156 | +## "Loan/ Repayable advances", | |
157 | +## "Loan/ Repayable advances", | |
158 | +## "Direct grant/ Interest rate subsidy", | |
159 | +## "Other", | |
160 | +## "Other forms of tax advantage", | |
161 | +## "Other forms of tax advantage", | |
162 | +## "Soft loan", | |
163 | +## "Provision of risk capital", | |
164 | +## "Repayable advances", | |
165 | +## "Other", | |
166 | +## "Direct grant", | |
167 | +## "Tax advantage or tax exemption" | |
168 | +## ) | |
169 | + | |
170 | + | |
171 | +aid_instr_new <- read_csv("instruments.csv") |> | |
172 | + pull(Interpretation) | |
161 | 173 | |
162 | 174 | |
163 | 175 | aid_instr <- df_sel |> |
164 | 176 | pull(aid_award_instrument) |> |
165 | 177 | su() |
166 | 178 | |
167 | -nace <- readRDS("../../nace_codes/df_nace.RDS") |> | |
179 | +nace <- readRDS("df_nace.RDS") |> | |
168 | 180 | select(-code2) |
169 | 181 | |
170 | 182 | df_nace <- tibble(macro=seq_fixed_width(1:99,2), |
@@ -215,17 +227,20 @@ | ||
215 | 227 | left_join(y=df_nace, by=c("ben_sec2"="macro")) |> |
216 | 228 | mutate(beneficiary_sector=paste(macro2, " - ", beneficiary_sector, |
217 | 229 | sep="")) |> |
218 | - select(-c(ben_sec2, macro2)) | |
230 | + select(-c(ben_sec2, macro2)) |> | |
231 | + mutate(aid_award_granted_date=as.Date(aid_award_granted_date), | |
232 | + aid_award_created_date=as.Date(aid_award_created_date), | |
233 | + national_identification_type=as.character(national_identification_type)) | |
219 | 234 | |
220 | 235 | |
221 | 236 | |
222 | 237 | |
223 | -saveRDS(df_sel2,"tam_PL_matched.RDS") | |
224 | -write_csv(df_sel2, "tam_PL_matched.csv.gz") | |
225 | -save_excel(df_sel2, "tam_PL_matched.xlsx") | |
238 | +## saveRDS(df_sel2,"tam_PL_matched.RDS") | |
239 | +## write_csv(df_sel2, "tam_PL_matched.csv.gz") | |
240 | +## save_excel(df_sel2, "tam_PL_matched.xlsx") | |
226 | 241 | |
227 | 242 | |
228 | -saveRDS(df_sel2,"tam_PL_matched_extended.RDS") | |
243 | +## saveRDS(df_sel2,"tam_PL_matched_extended.RDS") | |
229 | 244 | write_parquet(df_sel2,"tam_PL_matched_extended.parquet") |
230 | 245 | |
231 | 246 |