@@ -42,8 +42,7 @@ ui <- dashboardPage(
42
42
" civ" )),
43
43
uiOutput(" outui" ),
44
44
actionButton(" all" , " Select All" ),
45
- actionButton(" none" , " Select None" ),
46
- actionButton(" button" , " Plot" )
45
+ actionButton(" none" , " Select None" )
47
46
)
48
47
),
49
48
column(width = 8 ,
@@ -68,16 +67,21 @@ ui <- dashboardPage(
68
67
# # Server
69
68
70
69
server <- function (input , output , session ) {
71
- observeEvent(c(input $ i_country , input $ use , input $ slider ), {
70
+ # # Filter Data
71
+ observe({
72
72
year_select <- as.numeric(input $ slider )
73
73
cty_select <- input $ i_country
74
74
use_select <- input $ use
75
75
newdata <- all %> %
76
76
filter(
77
77
year %in% seq(from = year_select [1 ], to = year_select [2 ],
78
78
by = 1 ) & imp %in% cty_select & wc %in% use_select )
79
- # # mychoices is going to be used in the next observeEvent
79
+ # # mychoices and newdata is going to be used in the next observeEvent
80
+ assign(" newdata" , newdata , envir = globalenv())
80
81
assign(" mychoices" , unique(newdata $ e ), envir = globalenv())
82
+ })
83
+ # # Render UI
84
+ observeEvent(c(input $ i_country , input $ use ), {
81
85
output $ outui <- renderUI({
82
86
checkboxGroupInput(inputId = " e_country" ,
83
87
label = " Select the countries" ,
@@ -87,7 +91,8 @@ server <- function(input, output, session) {
87
91
# # newdata is going to be used in the next observeEvent
88
92
assign(" newdata" , newdata , envir = globalenv())
89
93
})
90
- observeEvent(input $ button , {
94
+ # # Plot
95
+ observeEvent(c(input $ i_country , input $ slider , input $ use , input $ e_country ), {
91
96
newdata <- newdata %> % filter(e %in% input $ e_country )
92
97
output $ outplot <- renderPlot({
93
98
ggplot(data = newdata ,
0 commit comments