Description Usage Arguments Value Note See Also Examples
reactable()
creates a data table from tabular data with sorting
and pagination by default. The data table is an HTML widget that can be
used in R Markdown documents and Shiny applications, or viewed from an
R console.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | reactable(
data,
columns = NULL,
columnGroups = NULL,
rownames = NULL,
groupBy = NULL,
sortable = TRUE,
resizable = FALSE,
filterable = FALSE,
searchable = FALSE,
defaultColDef = NULL,
defaultColGroup = NULL,
defaultSortOrder = "asc",
defaultSorted = NULL,
pagination = TRUE,
defaultPageSize = 10,
showPageSizeOptions = FALSE,
pageSizeOptions = c(10, 25, 50, 100),
paginationType = "numbers",
showPagination = NULL,
showPageInfo = TRUE,
minRows = 1,
details = NULL,
defaultExpanded = FALSE,
selection = NULL,
selectionId = NULL,
defaultSelected = NULL,
onClick = NULL,
highlight = FALSE,
outlined = FALSE,
bordered = FALSE,
borderless = FALSE,
striped = FALSE,
compact = FALSE,
wrap = TRUE,
showSortIcon = TRUE,
showSortable = FALSE,
class = NULL,
style = NULL,
rowClass = NULL,
rowStyle = NULL,
fullWidth = TRUE,
width = "auto",
height = "auto",
theme = getOption("reactable.theme"),
language = getOption("reactable.language"),
elementId = NULL
)
|
data |
A data frame or matrix. Can also be a |
columns |
Named list of column definitions. See |
columnGroups |
List of column group definitions. See |
rownames |
Show row names? Defaults to To customize the row names column, use |
groupBy |
Character vector of column names to group by. To aggregate data when rows are grouped, use the |
sortable |
Enable sorting? Defaults to |
resizable |
Enable column resizing? |
filterable |
Enable column filtering? |
searchable |
Enable global table searching? |
defaultColDef |
Default column definition used by every column. See |
defaultColGroup |
Default column group definition used by every column group.
See |
defaultSortOrder |
Default sort order. Either |
defaultSorted |
Character vector of column names to sort by default.
Or to customize sort order, a named list with values of |
pagination |
Enable pagination? Defaults to |
defaultPageSize |
Default page size for the table. Defaults to 10. |
showPageSizeOptions |
Show page size options? |
pageSizeOptions |
Page size options for the table. Defaults to 10, 25, 50, 100. |
paginationType |
Pagination control to use. Either |
showPagination |
Show pagination? Defaults to |
showPageInfo |
Show page info? Defaults to |
minRows |
Minimum number of rows to show per page. Defaults to 1. |
details |
Additional content to display when expanding a row. An R function
that takes a row index argument or a |
defaultExpanded |
Expand all rows by default? |
selection |
Enable row selection? Either To get the selected rows in Shiny, use To customize the selection column, use |
selectionId |
Shiny input ID for the selected rows. The selected rows are
given as a numeric vector of row indices, or |
defaultSelected |
A numeric vector of default selected row indices. |
onClick |
Action to take when clicking a cell. Either |
highlight |
Highlight table rows on hover? |
outlined |
Add borders around the table? |
bordered |
Add borders around the table and every cell? |
borderless |
Remove inner borders from table? |
striped |
Add zebra-striping to table rows? |
compact |
Make tables more compact? |
wrap |
Enable text wrapping? If |
showSortIcon |
Show a sort icon when sorting columns? |
showSortable |
Show an indicator on sortable columns? |
class |
Additional CSS classes to apply to the table. |
style |
Inline styles to apply to the table. A named list or character string. Note that if |
rowClass |
Additional CSS classes to apply to table rows. A character
string, a |
rowStyle |
Inline styles to apply to table rows. A named list, character
string, Note that if |
fullWidth |
Stretch the table to fill the full width of its container?
Defaults to |
width |
Width of the table in pixels. Defaults to To set the width of a column, see |
height |
Height of the table in pixels. Defaults to |
theme |
Theme options for the table, specified by
|
language |
Language options for the table, specified by
|
elementId |
Element ID for the widget. |
A reactable
HTML widget that can be used in R Markdown documents
and Shiny applications, or viewed from an R console.
See the online documentation for additional details and examples.
renderReactable()
and reactableOutput()
for using reactable
in Shiny applications or interactive R Markdown documents.
colDef()
, colFormat()
, and colGroup()
to customize columns.
reactableTheme()
and reactableLang()
to customize the table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # Basic usage
reactable(iris)
# Grouping and aggregation
reactable(iris, groupBy = "Species", columns = list(
Sepal.Length = colDef(aggregate = "count"),
Sepal.Width = colDef(aggregate = "mean"),
Petal.Length = colDef(aggregate = "sum"),
Petal.Width = colDef(aggregate = "max")
))
# Row details
reactable(iris, details = function(index) {
htmltools::div(
"Details for row: ", index,
htmltools::tags$pre(paste(capture.output(iris[index, ]), collapse = "\n"))
)
})
# Conditional styling
reactable(sleep, columns = list(
extra = colDef(style = function(value) {
if (value > 0) {
color <- "green"
} else if (value < 0) {
color <- "red"
} else {
color <- "#777"
}
list(color = color, fontWeight = "bold")
})
))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.