Revision | db3f264ed161cbc6a75db74b3dabddec6a54a665 (tree) |
---|---|
Zeit | 2022-09-22 19:38:45 |
Autor | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I now use the right variable for the scoreboard objectives.
@@ -165,10 +165,13 @@ | ||
165 | 165 | |
166 | 166 | df_sc <- df_sc_ini |> |
167 | 167 | select(member_state, expenditure_year, harmonised_aid_instrument, |
168 | - harmonised_primary_obj, aid_element_eur, case_number, | |
168 | + ## harmonised_primary_obj | |
169 | + scoreboard_objective | |
170 | + , aid_element_eur, case_number, | |
169 | 171 | case_type, co_financing_percentage, covid) |> |
170 | - mutate(harmonised_aid_instrument=remove_trailing_spaces(harmonised_aid_instrument), | |
171 | - harmonised_primary_obj=remove_trailing_spaces(harmonised_primary_obj) ) |> | |
172 | + ## mutate(harmonised_aid_instrument=remove_trailing_spaces(harmonised_aid_instrument)## , | |
173 | + ## ## harmonised_primary_obj=remove_trailing_spaces(harmonised_primary_obj) | |
174 | + ## ) |> | |
172 | 175 | filter(!is.na(aid_element_eur)) |
173 | 176 | |
174 | 177 | instrument <- df_sc |> |
@@ -177,7 +180,8 @@ | ||
177 | 180 | unique() |
178 | 181 | |
179 | 182 | objective <- df_sc |> |
180 | - pull(harmonised_primary_obj) |> | |
183 | + ## pull(harmonised_primary_obj) |> | |
184 | + pull(scoreboard_objective) |> | |
181 | 185 | sort() |> |
182 | 186 | unique() |
183 | 187 |
@@ -386,7 +390,8 @@ | ||
386 | 390 | ## expenditure_year %in% seq(2010,2020), |
387 | 391 | case_type %in% input$case_type, |
388 | 392 | harmonised_aid_instrument %in% input$instruments, |
389 | - harmonised_primary_obj %in% input$objectives | |
393 | + ## harmonised_primary_obj | |
394 | + scoreboard_objective %in% input$objectives | |
390 | 395 | ) |
391 | 396 | }) |
392 | 397 |
@@ -605,7 +610,7 @@ | ||
605 | 610 | |
606 | 611 | |
607 | 612 | data_sel() |> |
608 | - group_by(expenditure_year, harmonised_primary_obj ) |> | |
613 | + group_by(expenditure_year, scoreboard_objective ) |> | |
609 | 614 | summarise(exp_mio_eur=sum(aid_element_eur, na.rm=T)) |> |
610 | 615 | ungroup() |> |
611 | 616 | mutate(exp_mio_eur=round_preserve_sum(exp_mio_eur,2)) |
@@ -617,7 +622,7 @@ | ||
617 | 622 | objective_agg_long <- reactive({ |
618 | 623 | |
619 | 624 | data_sel() |> |
620 | - group_by(harmonised_primary_obj ) |> | |
625 | + group_by(scoreboard_objective ) |> | |
621 | 626 | summarise(exp_mio_eur=sum(aid_element_eur, na.rm=T)) |> |
622 | 627 | ungroup() |> |
623 | 628 | mutate(exp_mio_eur=round_preserve_sum(exp_mio_eur,2)) |> |
@@ -641,8 +646,8 @@ | ||
641 | 646 | |
642 | 647 | yearly_objective_agg_long_top <- reactive({ |
643 | 648 | yearly_objective_agg_long() |> |
644 | - mutate(harmonised_primary_obj_top=fct_lump_n(harmonised_primary_obj,k_levels, exp_mio_eur, "All Other Objectives")) |> | |
645 | - group_by(expenditure_year, harmonised_primary_obj_top) |> | |
649 | + mutate(scoreboard_objective_top=fct_lump_n(scoreboard_objective,k_levels, exp_mio_eur, "All Other Objectives")) |> | |
650 | + group_by(expenditure_year, scoreboard_objective_top) |> | |
646 | 651 | summarise(exp_mio_eur=sum(exp_mio_eur)) |> |
647 | 652 | ungroup() |
648 | 653 |
@@ -896,13 +901,13 @@ | ||
896 | 901 | |
897 | 902 | |
898 | 903 | n_colors <- yearly_objective_agg_long_top() |> |
899 | - pull(harmonised_primary_obj_top) |> | |
904 | + pull(scoreboard_objective_top) |> | |
900 | 905 | unique() |> |
901 | 906 | length() |
902 | 907 | |
903 | 908 | fig <- plot_ly(yearly_objective_agg_long_top(), |
904 | 909 | x = ~expenditure_year, y = ~exp_mio_eur, |
905 | - type = 'bar', color = ~harmonised_primary_obj_top, | |
910 | + type = 'bar', color = ~scoreboard_objective_top, | |
906 | 911 | ## symbol = ~anno, |
907 | 912 | colors = viridis_pal(option = "H")(n_colors)) %>% |
908 | 913 | layout(hovermode = "x unified",xaxis = list(title="", |
@@ -355,7 +355,7 @@ | ||
355 | 355 | ft <- objective_agg_long() |> |
356 | 356 | flextable() |> |
357 | 357 | ## add_header_row(values = c(paste("State Aid Measures in ", year_focus, sep="")) ) %>% |
358 | - set_header_labels(harmonised_primary_obj="Harmonized Objective", | |
358 | + set_header_labels(scoreboard_objective="Harmonized Objective", | |
359 | 359 | exp_mio_eur="Aid (mio EUR)", |
360 | 360 | percentage="Percentage of Total Aid", |
361 | 361 | cumulative_percentage="Cumulative Percentage" |
@@ -393,7 +393,7 @@ | ||
393 | 393 | |
394 | 394 | ggplot(data = yearly_objective_agg_long_top(), aes(x = expenditure_year, |
395 | 395 | y=exp_mio_eur, |
396 | - fill=harmonised_primary_obj_top)) + | |
396 | + fill=scoreboard_objective_top)) + | |
397 | 397 | geom_bar(position=position_dodge2(preserve="single"), stat="identity", alpha=1, color="black")+ |
398 | 398 | ## scale_fill_viridis("Vehicle Brand\nOrigin",breaks=mybreaks, labels= mylabels, discrete=T)+ |
399 | 399 | ## scale_colour_viridis("Vehicle Brand\nOrigin",breaks=mybreaks, labels= mylabels, discrete=T)+ |