• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision7ad70b93c0eb3ab7b535f564e08518313d4eaa1a (tree)
Time2023-05-05 19:28:32
AuthorLorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

I merged some heads.

Change Summary

Incremental Difference

diff -r e946b59fa3b6 -r 7ad70b93c0eb R-codes/read_polish_tam_new.R
--- a/R-codes/read_polish_tam_new.R Fri May 05 12:27:18 2023 +0200
+++ b/R-codes/read_polish_tam_new.R Fri May 05 12:28:32 2023 +0200
@@ -6,7 +6,7 @@
66 library(stringr)
77 library(lubridate)
88 library(RJSDMX)
9-library(haven)
9+## library(haven)
1010 library(arrow)
1111
1212
@@ -17,14 +17,20 @@
1717
1818 read_estat <- 0
1919
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()
2323
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()
2626
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")
2834
2935 query <- "ert_bil_eur_a/A.AVG.NAC.PLN"
3036
@@ -112,6 +118,8 @@
112118 select(all_of(column_selection)) |>
113119 rename_many( new_columns## [1:14]
114120 , 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"))) |>
115123 mutate(year=year(aid_award_granted_date ),
116124 beneficiary_country="Poland") |>
117125 left_join(y=all_rates_ini, by=c("year"="time_period")) |>
@@ -134,37 +142,41 @@
134142
135143
136144
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)
161173
162174
163175 aid_instr <- df_sel |>
164176 pull(aid_award_instrument) |>
165177 su()
166178
167-nace <- readRDS("../../nace_codes/df_nace.RDS") |>
179+nace <- readRDS("df_nace.RDS") |>
168180 select(-code2)
169181
170182 df_nace <- tibble(macro=seq_fixed_width(1:99,2),
@@ -215,17 +227,20 @@
215227 left_join(y=df_nace, by=c("ben_sec2"="macro")) |>
216228 mutate(beneficiary_sector=paste(macro2, " - ", beneficiary_sector,
217229 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))
219234
220235
221236
222237
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")
226241
227242
228-saveRDS(df_sel2,"tam_PL_matched_extended.RDS")
243+## saveRDS(df_sel2,"tam_PL_matched_extended.RDS")
229244 write_parquet(df_sel2,"tam_PL_matched_extended.parquet")
230245
231246