BaşlayınÜcretsiz Başlayın

Inserting multiple inputs

You can insert more than just one input. Suppose you also want app users to choose the average number of hours spent sleeping, as well as a specific year.

To this end, in the ui, you can insert another sliderInput() where the values are the years of interest.

In this exercise, the shiny library has already been loaded for you.

Bu egzersiz

Building Dashboards with shinydashboard

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Add another sliderInput() as a second input for your shinyApp and label it as "yearlabel".
  • Set the number range to be between 2003 and 2017.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

ui <- fluidPage(
  titlePanel("Sleeping habits in America"), 
  sliderInput("sliderlabel",
              "Average hours of sleep",
              min = 7.5, max = 11,
              value = 8, step = 0.5),
  # Add another sliderInput and label the input as "yearlabel"
  ___(___,
               "Year",
            # Set the number range to be between 2003 and 2017
               ___, ___,
               value = 2004, step = 1, sep = ""))
server <- function(input, output, session) {
}
shinyApp(ui, server)
Kodu Düzenle ve Çalıştır