LoslegenKostenlos loslegen

See the data in a table

An easy first step in exploring a dataset is to simply view it as a table.

So far we have focused mostly on inputs—interactive widgets that allow the user to select values. Now we want to have a table in our app, and send data to display in the table. To display objects in Shiny, we need to use output and render functions.

Diese Übung ist Teil des Kurses

Case Studies: Building Web Applications with Shiny in R

Kurs anzeigen

Anleitung zur Übung

Given a minimal Shiny app, add a table that will show the gapminder dataset. Specifically:

  • Add a placeholder for the table by creating a table output with ID "table" in the UI.
  • Use the corresponding render function in the server code to render the table.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

ui <- fluidPage(
  h1("Gapminder"),
  # Add a placeholder for a table output
  ___
)

server <- function(input, output) {
  # Call the appropriate render function 
  output$table <- ___({
    # Show the gapminder object in the table
    gapminder
  })
}

shinyApp(ui, server)
Code bearbeiten und ausführen