Interactive version of the dashboard can be accessed here

For this project, I created a dashboard from Open Sourcing Mental Illness’ 2014 Mental Health in Tech survey. In particular, I visualized the age distribution of the answers to two specific questions: “Do you think that discussing a mental health issue with your employer would have negative consequences?” and “Do you feel that your employer takes mental health as seriously as physical health?”

Dashboard is adapted from the “building web applications with Shiny in R” course by Kaelen Medeiros and all credit goes to the author for the original instruction.

Code can be found below.

library(shiny)
library(tidyverse)
library(janitor)
library(shinyWidgets)
library(shinythemes)
library(ggthemes)
mental_health_survey = read_csv("mhsurvey.csv") %>%clean_names()
ui <- fluidPage(theme = shinytheme("superhero"),
                # CODE BELOW: Add an appropriate title
                titlePanel("2014 Mental Health in Tech Survey"),
                sidebarPanel(
                  # CODE BELOW: Add a checkboxGroupInput
                  checkboxGroupInput(
                    inputId = "mental_health_consequence",
                    label = "Do you think that discussing a mental health issue with your employer would have negative consequences?",
                    choices = c("Maybe", "Yes", "No"),
                    selected = "Maybe"
                  ),
                  # CODE BELOW: Add a pickerInput
                  pickerInput(
                    inputId = "mental_vs_physical",
                    label = "Do you feel that your employer takes mental health as seriously as physical health?",
                    choices = c("Don't Know", "No", "Yes"),
                    multiple = TRUE
                  )
                ),
                mainPanel(
                  # CODE BELOW: Display the output
                  plotOutput("age")
                )
)

server <- function(input, output, session) {
  # CODE BELOW: Build a histogram of the age of respondents
  # Filtered by the two inputs
  output$age <- renderPlot({
    mental_health_survey %>%
      filter(
        mental_health_consequence %in% input$mental_health_consequence,
        mental_vs_physical %in% input$mental_vs_physical
      ) %>%
      ggplot(aes(age)) +
      geom_histogram(fill='#CC5500') + theme_classic()
  })
}

shinyApp(ui, server)