I have this shiny code below that I will like to improve on. The histogram is not showing and the sidebars are not working properly
library(shiny)
library(ggplot2)
#View(midwest)
# User interface ----
ui <- fluidPage(
titlePanel("Midwest"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "bins",
label = "Population Density",
min = 0, max = 8000, value = 2000, step = 1000),
radioButtons("radio",
label = "States",
choices = midwest$state,
selected = "IL"),
selectInput("select", "Population Total",
choices = midwest$poptotal)
),
mainPanel(plotOutput(outputId = "distPlot"),
tableOutput("view"))
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- midwest$area
x <- na.omit(x)
bins <- seq(min(x), max(x),length.out = input$bins +1)
hist(x, breaks = bins, col = "#003366", border = "white")
})
output$view <- renderTable({
head(midwest)
})
}
# Run the app ----
shinyApp(ui = ui, server = server)