Browse Source

Utilisation de req() pour éviter erreurs et warnings

master
Maxime Wack 7 years ago
parent
commit
79a1c69fd4
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      app.R

+ 9
- 3
app.R View File

@@ -83,8 +83,8 @@ server <- function(input, output, session)


# in bounds # in bounds
in_bounds <- reactive({ in_bounds <- reactive({
if (is.null(input$map_bounds))
return(communes[F,])
req(input$map_bounds)
bounds <- input$map_bounds bounds <- input$map_bounds
latrng <- range(bounds$north, bounds$south) latrng <- range(bounds$north, bounds$south)
lngrng <- range(bounds$east, bounds$west) lngrng <- range(bounds$east, bounds$west)
@@ -113,6 +113,8 @@ server <- function(input, output, session)


# GHM # GHM
data_ghm <- reactive({ data_ghm <- reactive({
req(input$slider_age, input$check_sexe, input$slider_date, in_bounds())

GHM %>% GHM %>%
filter(Age <= input$slider_age[2] & Age >= input$slider_age[1], filter(Age <= input$slider_age[2] & Age >= input$slider_age[1],
date_entree <= input$slider_date[2] & date_sortie >= input$slider_date[1], date_entree <= input$slider_date[2] & date_sortie >= input$slider_date[1],
@@ -124,7 +126,7 @@ server <- function(input, output, session)
data_ghm() %>% data_ghm() %>%
count(GHM, Sexe) %>% count(GHM, Sexe) %>%
semi_join(GHM %>% count(GHM) %>% top_n(10) %>% arrange(n), by = "GHM") %>% semi_join(GHM %>% count(GHM) %>% top_n(10) %>% arrange(n), by = "GHM") %>%
ungroup %>%
ungroup() %>%
mutate(GHM = GHM %>% factor(levels = GHM %>% unique)) %>% mutate(GHM = GHM %>% factor(levels = GHM %>% unique)) %>%
ggplot() + ggplot() +
aes(x = GHM, y = n, fill = Sexe) + aes(x = GHM, y = n, fill = Sexe) +
@@ -137,6 +139,8 @@ server <- function(input, output, session)


# Sexe # Sexe
data_sexe <- reactive({ data_sexe <- reactive({
req(input$slider_age, input$slider_date, in_bounds())

if (input$choice_ghm %>% is.null) if (input$choice_ghm %>% is.null)
{ {
GHM %>% GHM %>%
@@ -168,6 +172,8 @@ server <- function(input, output, session)


# Age # Age
data_age <- reactive({ data_age <- reactive({
req(input$slider_date, input$check_sexe, in_bounds())

if (input$choice_ghm %>% is.null) if (input$choice_ghm %>% is.null)
{ {
GHM %>% GHM %>%


Loading…
Cancel
Save