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.
本练习是课程的一部分
Building Web Applications with Shiny in R
练习说明
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.
交互式实操练习
通过完成这段示例代码来试试这个练习。
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)