• R/O
  • SSH

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revisiond253bdeb31b3f2c3d652f353954c619e3128eb9d (tree)
Zeit2021-09-16 18:50:16
AutorLorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

I modified both codes to deal better with NACE 1-digit categories.

Ändern Zusammenfassung

Diff

diff -r 3fa1d9b66ed0 -r d253bdeb31b3 R-codes/prepare_tam_data.R
--- a/R-codes/prepare_tam_data.R Thu Sep 16 09:34:57 2021 +0200
+++ b/R-codes/prepare_tam_data.R Thu Sep 16 11:50:16 2021 +0200
@@ -4,6 +4,8 @@
44 library(janitor)
55 library(openxlsx)
66 library(lubridate)
7+library(stringr)
8+library(stringi)
79
810 source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R")
911
@@ -24,7 +26,13 @@
2426
2527 }
2628
27-
29+
30+
31+
32+nace <- read_excel("nace_codes.xlsx") %>%
33+ mutate(code=substrLeft(description,1))
34+
35+
2836
2937 df <- df_ini %>%
3038 clean_tam() %>%
@@ -58,7 +66,11 @@
5866 find_text_replace("\\(leasing subsidy","leasing subsidy") %>%
5967 find_text_replace("leasing subsidy\\)","leasing subsidy") %>%
6068 find_text_replace("feed-in tariffs","feed-in tariff") %>%
61- find_text_replace("tarriif","tariff")
69+ find_text_replace("tarriif","tariff") %>%
70+ mutate(macro_sector=substrLeft(beneficiary_sector, 1)) %>%
71+ left_join(y=nace, by=c("macro_sector"="code")) %>%
72+ select(-macro_sector) %>%
73+ rename("macro_sector"="description")
6274
6375
6476
diff -r 3fa1d9b66ed0 -r d253bdeb31b3 R-codes/shiny_report_tam.R
--- a/R-codes/shiny_report_tam.R Thu Sep 16 09:34:57 2021 +0200
+++ b/R-codes/shiny_report_tam.R Thu Sep 16 11:50:16 2021 +0200
@@ -103,10 +103,16 @@
103103 unique %>%
104104 sort
105105
106-beneficiaries_sector <- df_ini$beneficiary_sector %>%
106+## beneficiaries_sector <- df_ini$beneficiary_sector %>%
107+## unique %>%
108+## sort
109+
110+
111+beneficiaries_sector <- df_ini$macro_sector %>%
107112 unique %>%
108113 sort
109114
115+
110116 truncated_beneficiaries_sector <- beneficiaries_sector %>%
111117 shiny_wrap(len_truncation)
112118
@@ -250,13 +256,15 @@
250256 compound_data <- reactive({
251257
252258 df_ini %>% filter(## is_co_finance %in% input$cofinanced,
253- year %in% input$year_award,
254- beneficiary_country %in% input$country ,
255- beneficiary_type %in% input$beneficiary_type,
256- beneficiary_sector %in% input$beneficiary_sector,
257- instrument_type %in% input$instrument_type,
259+ year %in% input$year_award,
260+ beneficiary_country %in% input$country ,
261+ beneficiary_type %in% input$beneficiary_type,
262+ ## beneficiary_sector %in% input$beneficiary_sector,
263+ macro_sector %in% input$beneficiary_sector,
264+
265+ instrument_type %in% input$instrument_type,
258266 ## main_procedure_type_code %in% input$procedure_code,
259- aid_objective %in% input$objectives)
267+ aid_objective %in% input$objectives)
260268
261269
262270 })
@@ -420,7 +428,7 @@
420428 output$downloadViz <- downloadHandler(
421429 filename = "plot.png" ,
422430 content = function(file) {
423- ggsave(myplot(), filename = file, width=12, height=6)
431+ ggsave(myplot(), filename = file, width=12, height=12)
424432
425433 })
426434