#Building a simple Shiny Dashboard library(shinydashboard) #Defining the body of the dashboard body <- dashboardBody( #The body consists of a row-based layout with a single fluid row fluidRow( #Defining the output within a box box(plotOutput("barplot")) ) ) #Defining the header object header <- dashboardHeader(title = "Boston Police") #Defining the sidebard object sidebar <- dashboardSidebar( radioButtons("year", "Select Year: ", c("2015" = "2015", "2016" = "2016", "2017" = "2017", "2018" = "2018", "2019" = "2019")) ) #Defining our ui object with a dashboardPage template ui <- dashboardPage(header, sidebar, body) server <- function(input, output) { output$barplot <- renderPlot({ df_fil <- filter(df, YEAR == input$year) ggplot(data = df_fil, aes(x = df_fil$HOUR)) + geom_bar() + xlab("Hour") + ylab("Number of Crimes") + theme_minimal() }) } shinyApp(ui, server)