Revisión | dd75d4b0efc15b7e57f53604d221f6e8289bc90e (tree) |
---|---|
Tiempo | 2023-01-31 06:56:27 |
Autor | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I added an option to save and read the ESTAT data.
@@ -15,6 +15,7 @@ | ||
15 | 15 | |
16 | 16 | ## df_ini2 <- read_excel("State_aid_in_Poland-2018-2019_above_500K_euro,_2020_above_100K_euro.xlsx") |
17 | 17 | |
18 | +read_estat <- 0 | |
18 | 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") |
20 | 21 | ) |> |
@@ -28,12 +29,21 @@ | ||
28 | 29 | query <- "ert_bil_eur_a/A.AVG.NAC.PLN" |
29 | 30 | |
30 | 31 | |
31 | -all_rates_ini <- estat_retrieval(query) %>% | |
32 | +if (read_estat!=1){ | |
33 | + all_rates_ini <- estat_retrieval(query) %>% | |
32 | 34 | clean_names() %>% |
33 | 35 | select(time_period, obs_value) %>% |
34 | 36 | mutate(time_period=as.numeric(time_period)) |
35 | 37 | |
36 | 38 | |
39 | + saveRDS(all_rates_ini, "all_rates.RDS") | |
40 | + | |
41 | + | |
42 | +} else{ | |
43 | + | |
44 | + | |
45 | + all_rates_ini <- readRDS("all_rates.RDS") | |
46 | +} | |
37 | 47 | |
38 | 48 | |
39 | 49 |
@@ -154,6 +164,8 @@ | ||
154 | 164 | pull(aid_award_instrument) |> |
155 | 165 | su() |
156 | 166 | |
167 | +nace <- readRDS("../../nace_codes/df_nace.RDS") |> | |
168 | + select(-code2) | |
157 | 169 | |
158 | 170 | |
159 | 171 |
@@ -163,7 +175,14 @@ | ||
163 | 175 | aid_instr_new)) |> |
164 | 176 | mutate(beneficiary_type=if_else(beneficiary_type %in% c("0","1","2"), |
165 | 177 | "Small and medium-sized enterprises", |
166 | - "Only large enterprises")) | |
178 | + "Only large enterprises")) |> | |
179 | + mutate(beneficiary_sector=case_match(beneficiary_sector, | |
180 | + "60.21"~"60.20", | |
181 | + .default=beneficiary_sector)) |> | |
182 | + left_join(y=nace, by=c("beneficiary_sector"="code")) |> | |
183 | + mutate(beneficiary_sector=paste(beneficiary_sector, description, | |
184 | + sep=" - ")) |> | |
185 | + select(-description) | |
167 | 186 | |
168 | 187 | |
169 | 188 | saveRDS(df_sel2,"tam_PL_matched.RDS") |