diff --git a/app.R b/app.R index aa5d93c..da94dcb 100644 --- a/app.R +++ b/app.R @@ -83,8 +83,8 @@ server <- function(input, output, session) # in bounds in_bounds <- reactive({ - if (is.null(input$map_bounds)) - return(communes[F,]) + req(input$map_bounds) + bounds <- input$map_bounds latrng <- range(bounds$north, bounds$south) lngrng <- range(bounds$east, bounds$west) @@ -113,6 +113,8 @@ server <- function(input, output, session) # GHM data_ghm <- reactive({ + req(input$slider_age, input$check_sexe, input$slider_date, in_bounds()) + GHM %>% filter(Age <= input$slider_age[2] & Age >= input$slider_age[1], date_entree <= input$slider_date[2] & date_sortie >= input$slider_date[1], @@ -124,7 +126,7 @@ server <- function(input, output, session) data_ghm() %>% count(GHM, Sexe) %>% semi_join(GHM %>% count(GHM) %>% top_n(10) %>% arrange(n), by = "GHM") %>% - ungroup %>% + ungroup() %>% mutate(GHM = GHM %>% factor(levels = GHM %>% unique)) %>% ggplot() + aes(x = GHM, y = n, fill = Sexe) + @@ -137,6 +139,8 @@ server <- function(input, output, session) # Sexe data_sexe <- reactive({ + req(input$slider_age, input$slider_date, in_bounds()) + if (input$choice_ghm %>% is.null) { GHM %>% @@ -168,6 +172,8 @@ server <- function(input, output, session) # Age data_age <- reactive({ + req(input$slider_date, input$check_sexe, in_bounds()) + if (input$choice_ghm %>% is.null) { GHM %>%