Data Viewer Module Server
Arguments
- id
Module id.
- data
Reactive returning a data frame. Supported column classes are numeric, integer, character, factor, logical,
Date, andPOSIXct/POSIXt.- top_n
Maximum number of categorical levels to keep in compact summary views before collapsing the remainder into
"Other".- default_page_size
Optional default number of rows to show in the table. If
NULL, the module shows all rows up to the largest page-size option.- page_size_options
Page-size options shown in the table controls.
- searchable
Whether the table search box is enabled.
- filterable
Whether column filters are enabled.
- sortable
Whether column sorting is enabled.
- summary_card_fn
Function used to render each variable summary card. It must accept at least
(summary_row, index)and return a Shiny UI tag.- reactable_theme
Optional
reactable::reactableTheme()object. IfNULL, the module uses its built-in theme.- default_col_def
Optional default
reactable::colDef()to apply to all columns. IfNULL, the module uses its built-in default column definition.- reactable_args
Optional named list of additional arguments passed to
reactable::reactable(). These values override the module defaults.
Examples
custom_summary_card <- function(summary_row, index) {
htmltools::tags$div(
class = "custom-summary-card",
sprintf("%s: %s", summary_row$var_name[[1]], summary_row$type[[1]])
)
}
ui <- bslib::page_fillable(
theme = bslib::bs_theme(version = 5),
data_viewer_card_ui("viewer", title = "Iris")
)
server <- function(input, output, session) {
data_viewer_server(
"viewer",
data = shiny::reactive(iris),
searchable = TRUE,
filterable = TRUE,
sortable = TRUE,
summary_card_fn = custom_summary_card
)
}
if (interactive()) {
shiny::shinyApp(ui, server)
}
