Skip to content

Commit 3d491d1

Browse files
committed
Remove botao dfe plot e faz plot iterativo
1 parent 7a2eb57 commit 3d491d1

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

.Rhistory

+7
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@ args(updateCheckboxGroupInput)
22
shinyApp(ui, server)
33
sidebarMenu
44
install.packages("shinydashboard")
5+
library(shiny)
6+
library(shinydashboard)
7+
install.packages("shinydashboard")
8+
library(shinydashboard)
9+
shinyApp(ui,server)
10+
observe
11+
observe

app.R

+10-5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ ui <- dashboardPage(
4242
"civ")),
4343
uiOutput("outui"),
4444
actionButton("all", "Select All"),
45-
actionButton("none", "Select None"),
46-
actionButton("button", "Plot")
45+
actionButton("none", "Select None")
4746
)
4847
),
4948
column(width = 8,
@@ -68,16 +67,21 @@ ui <- dashboardPage(
6867
## Server
6968

7069
server <- function(input, output, session) {
71-
observeEvent(c(input$i_country, input$use, input$slider), {
70+
## Filter Data
71+
observe({
7272
year_select <- as.numeric(input$slider)
7373
cty_select <- input$i_country
7474
use_select <- input$use
7575
newdata <- all %>%
7676
filter(
7777
year %in% seq(from = year_select[1], to = year_select[2],
7878
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())
8081
assign("mychoices", unique(newdata$e), envir = globalenv())
82+
})
83+
## Render UI
84+
observeEvent(c(input$i_country, input$use), {
8185
output$outui <- renderUI({
8286
checkboxGroupInput(inputId = "e_country",
8387
label = "Select the countries",
@@ -87,7 +91,8 @@ server <- function(input, output, session) {
8791
## newdata is going to be used in the next observeEvent
8892
assign("newdata", newdata, envir = globalenv())
8993
})
90-
observeEvent(input$button, {
94+
## Plot
95+
observeEvent(c(input$i_country, input$slider, input$use, input$e_country), {
9196
newdata <- newdata %>% filter(e %in% input$e_country)
9297
output$outplot <- renderPlot({
9398
ggplot(data = newdata,

0 commit comments

Comments
 (0)