R/mod_bivariate_bar.R

Defines functions bivar_bar_server bivar_bar_ui

#' @import shiny
#'
#'

select_choices <- c(
  "Rank Now"                  = "rank_now"
  ,"Rank Incident"            = "rank_incident"
  ,"Officer Ethnicity"        = "mos_ethnicity"
  ,"Officer Gender"           = "mos_gender"
  # ,"Officer Age Incident"     = "mos_age_incident"
  ,"Complainant Ethnicity"    = "complainant_ethnicity5"
  ,"Complainant Gender"       = "complainant_gender4"
  # ,"Complainant Age Incident" = "complainant_age_incident"
  ,"Category of Complaint"    = "fado_type"
  ,"Board Disposition"        = "disposition"
  ,"Pentalty"                 = "penalty"
)




bivar_bar_ui <- function(id){
  tagList(
    fluidRow(
      column(
        width = 2
        ,shinydashboard::box(
          title = "Choose Variables"
          ,width  = NULL
          ,selectInput(
            NS(id,"xvar")
            ,label = "Group by ..."
            ,choices = select_choices
          )
          ,selectInput(
            NS(id,"yvar")
            ,label = "Color by ..."
            ,choices = select_choices
          )
        )
      )
      ,column(
        width = 10
        ,shinydashboard::box(
          width = NULL
          ,plotOutput(
            NS(id,"bivar_bar_plot")
            ,height = "700px"
          )
        )
      )
    )
  )
}


bivar_bar_server <- function(id){
  moduleServer(id, function(input, output, session){

    output$bivar_bar_plot <- renderPlot({


      make_bi_bar_graph(nypd_ccrb_cleaned, input$xvar, input$yvar)


    })

  })
}
dss-hmi/nypd-ccrb-2020-shiny documentation built on Jan. 17, 2021, 12:17 a.m.