Table

#| standalone: true
#| components: [viewer]
#| viewerHeight: 200

library(shiny)
library(bslib)
library(palmerpenguins)

ui <- page_fluid(
  tableOutput("table") 
)

server <- function(input, output) {
  output$table <- renderTable(penguins, striped = TRUE) 
}

shinyApp(ui = ui, server = server)
library(shiny)
library(bslib)
library(palmerpenguins)

ui <- page_fluid(
  tableOutput("table") 
)

server <- function(input, output) {
  output$table <- renderTable(penguins, striped = TRUE) 
}

shinyApp(ui = ui, server = server)
No matching items

Relevant Functions

  • tableOutput
    tableOutput(outputId)

  • renderTable
    renderTable(expr, striped = FALSE, hover = FALSE, bordered = FALSE, spacing = c("s", "xs", "m", "l"), width = "auto", align = NULL, rownames = FALSE, colnames = TRUE, digits = NULL, na = "NA", ..., env = parent.frame(), quoted = FALSE, outputArgs = list())

No matching items

Details

To make a reactive table, follow three steps:

  1. Call tableOutput() in the UI of your app to create a div in which to display the table. Where you call this function within the UI functions will determine where the table will appear within the layout of the app. Set the outputId argument of tableOutput() to a unique value.

  2. Within the server function, call renderTable() and save its output as an element of the output list. Name the element after the outputId used above. For example, output$table <- renderTable(). tableOutput() will display the value of the output element whose name matches its outputId.

  3. Pass renderTable() either a table object, or a block of code, surrounded with {}, that returns a table. The table must R object that can be used with xtable::xtable().

  4. Optionally, use the other arguments (e.g., striped, hover) of renderTable() to control the appearance and behavior of the table.