##Excel file may need cleanup
library(data.table)

Career_Projections<- read.csv("Career_Projections.csv")
Career_Projections<- Career_Projections %>%
  select(Institution_Name, Select_a_State, Degree_Title, Career_Title, 
         Employment..2019, Employment..2029, Employment_Change_Number, 
         Employment_Change_Percent,Average_Anual_Openings, Median_Annual_Wage_2020, 
         Required_Education, Required_Job_Experience)

ui <- fluidPage(
  h1("Degrees and Job Projections", align = "center"),
  h2("IPEDS and U.S. Department of Labor Data (2018)", align = "center"),
   pickerInput("stateInputd2", "Select or type one or more states",
              choices = sort(unique(Career_Projections$Select_a_State)),
              options = list('actions-box' = TRUE), 
              multiple = TRUE,
              selected = "AK"), 
  pickerInput("instInputd2", "Select or type one or more institutions:",
              choices = sort(unique(Career_Projections$Institution_Name)),
              options = list('actions-box' = TRUE),
              multiple = TRUE),
  pickerInput("degreeInput2", "Select or type one or more degrees:",
              choices = sort(unique(Career_Projections$Degree_Title)),
              options = list('actions-box' = TRUE), 
              multiple = TRUE),
  downloadButton("dataset", "Download Institution Data"),
  
 
  
  mainPanel(width = 10,
    DT::dataTableOutput("projections")))
      
    


server <- function(input, output, session){
  
   state_deg2 <- reactive({
    filter(Career_Projections, Select_a_State %in% input$stateInputd2)
  })
  observeEvent(state_deg2(), {
    choices <- sort(unique(state_deg2()$Institution_Name))
    updatePickerInput(session = session, inputId = "instInputd2", choices = choices, selected = Career_Projections$Institution_Name) 
  })
  
  institution_deg2 <- reactive({
    req(input$instInputd2)
    filter(state_deg2(), Institution_Name %in% input$instInputd2)
  })
  observeEvent(institution_deg2(), {
    choices <- sort(unique(institution_deg2()$Degree_Title))
    updatePickerInput(session = session, inputId = "degreeInput2", choices = choices, selected = Career_Projections$Degree_Title)
  })
  
   output$dataset <- downloadHandler(
      filename = function() {
        paste("dataset", ".csv", sep="")
      },
      content = function(file) {
        write.csv(institution_deg2()%>%
        filter(Degree_Title %in% input$degreeInput2), file)
      }
      
    
    )
   

  
output$projections <- DT::renderDataTable(options= list(autoWidth=TRUE, scrollX = TRUE, searching = FALSE),{
  
  
    req(input$degreeInput2)
    institution_deg2()%>%
    filter(Degree_Title %in% input$degreeInput2) %>% 
    select(Institution_Name, Select_a_State, Degree_Title, Career_Title, 
         Employment..2019, Employment..2029, Employment_Change_Number, 
         Employment_Change_Percent,Average_Anual_Openings, Median_Annual_Wage_2020, 
         Required_Education, Required_Job_Experience)
 }) 
}



shinyApp(ui=ui, server=server)
## PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.

Shiny applications not supported in static R Markdown documents