Alien sightings: add outputs
Now that the dashboard has inputs, you should build your outputs to actually see information about the reported UFO sightings.
Recall there will be two, a plot and a table. The plot should show the number sighted, by shape, for the selected state and time period. The table should show, for the selected state and time period, the number sighted, plus the average, median, minimum, and maximum duration (duration_sec
) of the sightings. This will require using dplyr
, or a method of your choosing, to manipulate the usa_ufo_sightings
data.
This exercise is part of the course
Building Web Applications with Shiny in R
Exercise instructions
Add a bar plot output named
'shapes'
, showing the number of UFOs sighted, by shape, for the selected state and time period.Make sure to create the output in the server, and also display it in the UI.
Add a table output showing named
'duration_table'
, by shape, the number of UFOs sighted, plus the average, median, minimum, and maximum duration of the sightings. Note that the table should only show data for the selected state and time period.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
ui <- fluidPage(
titlePanel("UFO Sightings"),
sidebarLayout(
sidebarPanel(
selectInput("state", "Choose a U.S. state:", choices = unique(usa_ufo_sightings$state)),
dateRangeInput("dates", "Choose a date range:",
start = "1920-01-01",
end = "1950-01-01")
),
mainPanel(
# Add plot output named 'shapes'
# Add table output named 'duration_table'
)
)
)
server <- function(input, output) {
# CODE BELOW: Create a plot output of sightings by shape,
# For the selected inputs
# CODE BELOW: Create a table output named 'duration_table', by shape,
# of # sighted, plus mean, median, max, and min duration of sightings
# for the selected inputs
}
shinyApp(ui, server)