How to input data from dataframe into histogram in Shiny

library(DT) # when selecting multiple columns need to install this package
Hi, can someone help me here. I am trying to create a page with dropdown select input where I have all US states, so when one or more states is selected, I want the histogram to display respective covid data. But for some reason Shiny is asking me to use unlist etc.... I tried to use unlist as well, but then it says x must be numeric. My data source is dataframe with 2 columns i.e. States (character) and Covid_data (numeric values).
States Covid_Data
Alabama 1000
California 2000
New York 10000...etc

ui <- fluidPage(
  titlePanel(title = h2("Covid Data across US States", align = "center")),


      sidebarPanel( (""),
              SelectInput("State","State Name",choices = 
 final_US_Sum_Data$States, selected = "Alabama", selectize = FALSE, multiple = TRUE),
                    tabPanel("Histogram", plotOutput("myhist")),
                    tabPanel("Data", tableOutput("mydata"))
                                        )         )     )
server <- function(input, output) {
    output$mydata <- renderTable({
  output$myhist <- renderPlot({
     hist(final_US_Sum_Data[ , input$States,], xlab = "States", ylab = "count") 
shinyApp(ui, server)

You're more likely to get help if you start with a reprex:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.