• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

修订版082eeb956ebbf189225ee7876805858ecc64f376 (tree)
时间2022-09-17 04:35:33
作者Lorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

I fixed a bug and added another visualization.

更改概述

差异

diff -r 031d01690f5b -r 082eeb956ebb R-codes/shiny_scoreboard.R
--- a/R-codes/shiny_scoreboard.R Fri Sep 16 16:27:16 2022 +0200
+++ b/R-codes/shiny_scoreboard.R Fri Sep 16 21:35:33 2022 +0200
@@ -330,7 +330,16 @@
330330 conditionalPanel(condition = "input.type_aggregation == 'year_casenumber' ",
331331 dt_output2("Data selection","table6") ),
332332
333-
333+
334+
335+
336+ conditionalPanel(condition = "input.type_aggregation == 'year_casenumber' ",
337+ plotlyOutput("myplot5" ) )
338+
339+
340+
341+
342+
334343 )
335344
336345
@@ -476,7 +485,10 @@
476485 yearly_instrument_agg_long_top <- reactive({
477486
478487 yearly_instrument_agg_long() |>
479- mutate(harmonised_aid_instrument_top=fct_lump_n(harmonised_aid_instrument,k_levels, exp_mio_eur, "All Other Instruments"))
488+ mutate(harmonised_aid_instrument_top=fct_lump_n(harmonised_aid_instrument,k_levels, exp_mio_eur, "All Other Instruments")) |>
489+ group_by(expenditure_year,harmonised_aid_instrument_top) |>
490+ summarise(exp_mio_eur=sum(exp_mio_eur)) |>
491+ ungroup()
480492
481493 })
482494
@@ -522,7 +534,10 @@
522534
523535 yearly_objective_agg_long_top <- reactive({
524536 yearly_objective_agg_long() |>
525- mutate(harmonised_primary_obj_top=fct_lump_n(harmonised_primary_obj,k_levels, exp_mio_eur, "All Other Objectives"))
537+ mutate(harmonised_primary_obj_top=fct_lump_n(harmonised_primary_obj,k_levels, exp_mio_eur, "All Other Objectives")) |>
538+ group_by(expenditure_year, harmonised_primary_obj_top) |>
539+ summarise(exp_mio_eur=sum(exp_mio_eur)) |>
540+ ungroup()
526541
527542 })
528543
@@ -541,19 +556,59 @@
541556
542557
543558
544- yearly_casenumber_agg <- reactive({
559+ ## yearly_casenumber_agg <- reactive({
560+
561+
562+ ## data_sel() |>
563+ ## group_by(expenditure_year, case_number ) |>
564+ ## summarise(exp_mio_eur=sum(aid_element_eur, na.rm=T)) |>
565+ ## ungroup() |>
566+ ## mutate(exp_mio_eur=round_preserve_sum(exp_mio_eur,2)) |>
567+ ## make_wide_with_total("expenditure_year", "exp_mio_eur") ## |>
568+ ## ## arrange(desc(`All years`))
569+
570+ ## })
571+
572+
573+ yearly_casenumber_agg_long <- reactive({
545574
546575
547576 data_sel() |>
548577 group_by(expenditure_year, case_number ) |>
549578 summarise(exp_mio_eur=sum(aid_element_eur, na.rm=T)) |>
550579 ungroup() |>
551- mutate(exp_mio_eur=round_preserve_sum(exp_mio_eur,2)) |>
580+ mutate(exp_mio_eur=round_preserve_sum(exp_mio_eur,2)) ## |>
581+ ## make_wide_with_total("expenditure_year", "exp_mio_eur") ## |>
582+ ## ## arrange(desc(`All years`))
583+
584+ })
585+
586+
587+ yearly_casenumber_agg_long_top <- reactive({
588+
589+ yearly_casenumber_agg_long() |>
590+ mutate(case_number_top=fct_lump_n(case_number,
591+ k_levels, exp_mio_eur, "All Other Cases")) |>
592+ group_by(expenditure_year,case_number_top) |>
593+ summarise(exp_mio_eur=sum(exp_mio_eur)) |>
594+ ungroup()
595+
596+
597+ })
598+
599+
600+ yearly_casenumber_agg <- reactive({
601+
602+ yearly_casenumber_agg_long() |>
603+
552604 make_wide_with_total("expenditure_year", "exp_mio_eur") ## |>
553605 ## arrange(desc(`All years`))
554606
555607 })
556608
609+
610+
611+
557612
558613
559614 numeric_cols1 <- reactive({data_sel() |>
@@ -737,6 +792,44 @@
737792
738793
739794
795+
796+
797+
798+
799+ myplot5 <- reactive({
800+
801+
802+
803+ n_colors <- yearly_casenumber_agg_long_top() |>
804+ pull(case_number_top) |>
805+ unique() |>
806+ length()
807+
808+ fig <- plot_ly(yearly_casenumber_agg_long_top(),
809+ x = ~expenditure_year, y = ~exp_mio_eur,
810+ type = 'bar', color = ~case_number_top,
811+ ## symbol = ~anno,
812+ colors = viridis_pal(option = "H")(n_colors)) %>%
813+ layout(hovermode = "x unified",xaxis = list(title="",
814+ tickformat="%d %b"),
815+ yaxis = list(title = 'Scoreboard Expenditure (Mio \u20ac)'),
816+ font = t) |>
817+layout(legend = list(orientation = "h", # show entries horizontally
818+ xanchor = "center", # use center of legend as anchor
819+ x = 0.5, y=1.1)) # put legend in center of x-axis
820+
821+
822+
823+})
824+
825+
826+ output$myplot5 <- renderPlotly({
827+ myplot5()
828+
829+ })
830+
831+
832+
740833
741834
742835