From cdcf6dcc9b77e38696e6b6043313bacf6a30baa1 Mon Sep 17 00:00:00 2001 From: Maxime Wack Date: Mon, 6 Mar 2017 20:37:42 +0100 Subject: [PATCH] Plot sexe --- app.R | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/app.R b/app.R index 580970d..9a9a604 100644 --- a/app.R +++ b/app.R @@ -132,28 +132,37 @@ server <- function(input, output, session) theme(axis.title = element_blank()) }) - # observe({ - # output$plot_age <- renderPlotly({ - # filteredData() %>% - # ( - # ggplot() + - # aes(x = Age, y = ..density..) + - # geom_histogram() + - # geom_density() - # ) %>% ggplotly - # }) - # }) - # observe({ - # leafletProxy("map", data = in_bounds()) %>% - # clearShapes() %>% - # }) - # Use a separate observer to recreate the legend as needed. - # observe({ - # Remove any existing legend, and only if the legend is - # enabled, create a new one. - # leafletProxy("map", data = quakes) %>% - # clearControls() - # if (input$legend) { + # Sexe + data_sexe <- reactive({ + if (input$choice_ghm %>% is.null) + { + GHM %>% + filter(Age <= input$slider_age[2] & Age >= input$slider_age[1], + date_entree <= input$slider_date[2] & date_sortie >= input$slider_date[1], + CP %in% in_bounds()$Codepos) + } else + { + GHM %>% + filter(Age <= input$slider_age[2] & Age >= input$slider_age[1], + GHM %in% input$choice_ghm, + date_entree <= input$slider_date[2] & date_sortie >= input$slider_date[1], + CP %in% in_bounds()$Codepos) + } + }) + + output$plot_sexe <- renderPlot({ + data_sexe() %>% + ggplot() + + aes(x = 1, fill = Sexe) + + geom_bar() + + coord_flip() + + scale_fill_manual(values = c("Homme" = "lightblue", "Femme" = "pink")) + + theme(axis.title = element_blank(), + legend.position = "none", + axis.text.y = element_blank(), + axis.ticks.y = element_blank()) + }) + # pal <- colorpal() # proxy %>% addLegend(position = "bottomright", # pal = pal, values = ~mag