Hi
library(DT) # when selecting multiple columns need to install this package
library(shiny)
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).
Dataframe:
States Covid_Data
Alabama 1000
California 2000
New York 10000...etc
ui <- fluidPage(
titlePanel(title = h2("Covid Data across US States", align = "center")),
sidebarLayout(
sidebarPanel( (""),
SelectInput("State","State Name",choices =
final_US_Sum_Data$States, selected = "Alabama", selectize = FALSE, multiple = TRUE),
br(),
mainPanel(
tabsetPanel(type="tab",
tabPanel("Histogram", plotOutput("myhist")),
tabPanel("Data", tableOutput("mydata"))
) ) )
server <- function(input, output) {
output$mydata <- renderTable({
final_US_Sum_Data
output$myhist <- renderPlot({
hist(final_US_Sum_Data[ , input$States,], xlab = "States", ylab = "count")
})
}
shinyApp(ui, server)