MulaiMulai sekarang secara gratis

textOutput with interactions

Suppose you work for a sleep clinic in America. In your efforts to ascertain the sleep hygiene of Americans, you carried out a survey. Now that you have data, you would like to report your findings.

Instead of submitting a static report, you decide that an interactive application will be more engaging for your audience.

Suppose you would first like your user to input her city of residence as part of the user experience. This should be done in such a way that the text output will be updated based on what the user enters.

To this end, you will work with the textInput() function.

Latihan ini adalah bagian dari kursus

Building Dashboards with shinydashboard

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

ui <- fluidPage(
  titlePanel("Sleeping habits in America"), 
  # Add textInput and label it as "city label"
  ___(___,
            "Which city do you live in?",
            # Leave the value blank and set the placeholder as "Singapore"
            value = ___, placeholder = ___))

server <- function(input, output) {
}

shinyApp(ui, server)
Edit dan Jalankan Kode