Title: | R Bindings for 'Tabulator JS' |
---|---|
Description: | Provides R bindings for 'Tabulator JS' <https://tabulator.info/>. Makes it a breeze to create highly customizable interactive tables in 'rmarkdown' documents and 'shiny' applications. It includes filtering, grouping, editing, input validation, history recording, column formatters, packaged themes and more. |
Authors: | Stefan Kuethe [aut, cre, cph], Nico Friess [aut], Oli Folkerd [cph] (Author of included tabulator.js library) |
Maintainer: | Stefan Kuethe <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.2.9000 |
Built: | 2025-02-12 05:41:53 UTC |
Source: | https://github.com/eoda-dev/rtabulator |
Add row to table
add_row(ctx, row = NULL)
add_row(ctx, row = NULL)
ctx |
A |
row |
(list): row data or |
A tabulatorContext()
object
tabulatorContext("table") |> add_row()
tabulatorContext("table") |> add_row()
Delete selected rows from table
delete_selected_rows(ctx)
delete_selected_rows(ctx)
ctx |
A |
A tabulatorContext()
object
tabulatorContext("table") |> delete_selected_rows()
tabulatorContext("table") |> delete_selected_rows()
Apply a column setter function to multiple columns
for_each_col(widget, columns = NULL, .f, ...)
for_each_col(widget, columns = NULL, .f, ...)
widget |
A |
columns |
(character vector): The columns the column setter function ( |
.f |
(function): The column setter function that updates the column settings. |
... |
Arguments that are passed to |
The updated tabulator()
HTML widget
numeric_cols <- c("Sepal_Length", "Sepal_Width", "Petal_Length", "Petal_Width") tabulator(iris) |> for_each_col(numeric_cols, .f = set_header_filter, type = "number", func = "<=")
numeric_cols <- c("Sepal_Length", "Sepal_Width", "Petal_Length", "Petal_Width") tabulator(iris) |> for_each_col(numeric_cols, .f = set_header_filter, type = "number", func = "<=")
Modify column definition
modify_col_def(widget, columns, col_update)
modify_col_def(widget, columns, col_update)
widget |
A |
columns |
The names of the columns the formatter is applied to. |
col_update |
A named list containing the updates to apply to each column in |
The updated tabulator()
HTML widget
df <- data.frame(values = c(1,2,3), names = c("a","b","c")) tabulator(df) |> modify_col_def(c("values","names"), col_update = list(hozAlign = "center"))
df <- data.frame(values = c(1,2,3), names = c("a","b","c")) tabulator(df) |> modify_col_def(c("values","names"), col_update = list(hozAlign = "center"))
Redo changes
redo(ctx)
redo(ctx)
ctx |
A |
A tabulatorContext()
object
tabulatorContext("table") |> redo()
tabulatorContext("table") |> redo()
Output and render functions for using rtabulator within Shiny applications and interactive Rmd documents.
tabulatorOutput(outputId, width = "100%", height = "400px") renderTabulator(expr, env = parent.frame(), quoted = FALSE)
tabulatorOutput(outputId, width = "100%", height = "400px") renderTabulator(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a rtabulator |
env |
The environment in which to evaluate |
quoted |
Is |
Components for use inside a Shiny app.
Set calculation
set_calculation( widget, columns, func = c("avg", "max", "min", "sum", "count", "unique"), precision = 2, pos = c("top", "bottom") )
set_calculation( widget, columns, func = c("avg", "max", "min", "sum", "count", "unique"), precision = 2, pos = c("top", "bottom") )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
func |
(character): The calculation function to be applied
to the values of the |
precision |
(integer) The number of decimals to display.
Set to |
pos |
(character): Position at which calculated values are displayed. |
The updated tabulator()
HTML widget
tabulator(iris) |> set_calculation("Sepal_Length", "avg")
tabulator(iris) |> set_calculation("Sepal_Length", "avg")
Set column defaults
set_column_defaults( widget, editor = FALSE, header_filter = FALSE, header_sort = TRUE, tooltip = TRUE, width = NULL, ... )
set_column_defaults( widget, editor = FALSE, header_filter = FALSE, header_sort = TRUE, tooltip = TRUE, width = NULL, ... )
widget |
A |
editor |
(character, bool): One of |
header_filter |
(character, bool): One of |
header_sort |
(bool): Whether to enable header sorting. |
tooltip |
(bool): Whether to show tooltips displaying the cell value. |
width |
(integer): Fixed width of columns. |
... |
Additional settings. |
The updated tabulator()
HTML widget
https://tabulator.info/docs/6.2/columns#defaults
tabulator(iris, theme = "simple") |> set_column_defaults( header_filter = TRUE, header_sort = FALSE, tooltip = TRUE )
tabulator(iris, theme = "simple") |> set_column_defaults( header_filter = TRUE, header_sort = FALSE, tooltip = TRUE )
The input editor allows entering of a single line of plain text
set_column_editor_input( widget, columns, search = TRUE, mask = "", select_contents = TRUE, elementAttributes = list(maxlength = 10) )
set_column_editor_input( widget, columns, search = TRUE, mask = "", select_contents = TRUE, elementAttributes = list(maxlength = 10) )
widget |
A |
columns |
The name of the column the formatter is applied to. |
search |
Use search type input element with clear button |
mask |
Apply a mask to the input to allow characters to be entered only in a certain order |
select_contents |
When the editor is loaded select its text content |
elementAttributes |
Set attributes directly on the input element |
The updated tabulator()
HTML widget
df <- data.frame(values = c(1,2,3), names = c("a","b","c")) tabulator(df) |> set_column_editor_input("names")
df <- data.frame(values = c(1,2,3), names = c("a","b","c")) tabulator(df) |> set_column_editor_input("names")
The numeric editor allows for numeric entry with a number type input element with increment and decrement buttons.
set_column_editor_numeric( widget, columns, min = 0, max = 100, step = 1, elementAttributes = list(maxlength = 10), mask = "", select_contents = TRUE, vertical_navigation = "table" )
set_column_editor_numeric( widget, columns, min = 0, max = 100, step = 1, elementAttributes = list(maxlength = 10), mask = "", select_contents = TRUE, vertical_navigation = "table" )
widget |
A |
columns |
The name of the column the formatter is applied to. |
min |
the maximum allowed value |
max |
the minimum allowed value |
step |
the step size when incrementing/decrementing the value (default 1) |
elementAttributes |
Set attributes directly on the element |
mask |
Apply a mask to the input to allow characters to be entered only in a certain order |
select_contents |
When the editor is loaded select its text content |
vertical_navigation |
determine how use of the up/down arrow keys will affect the editor, this can take two different types of value: : editor and table |
The updated tabulator()
HTML widget
The textarea editor allows entering of multiple lines of plain text
set_column_editor_text_area( widget, columns, elementAttributes = list(maxlength = 10), mask = "", select_contents = TRUE, vertical_navigation = "editor", shift_enter_submit = TRUE )
set_column_editor_text_area( widget, columns, elementAttributes = list(maxlength = 10), mask = "", select_contents = TRUE, vertical_navigation = "editor", shift_enter_submit = TRUE )
widget |
A |
columns |
The name of the column the formatter is applied to. |
elementAttributes |
Set attributes directly on the textarea element |
mask |
Apply a mask to the input to allow characters to be entered only in a certain order |
select_contents |
When the editor is loaded select its text content |
vertical_navigation |
Determine how use of the up/down arrow keys will affect the editor, this can take three different types of value: hybrid, editor and table |
shift_enter_submit |
Submit the cell value when the shift and enter keys are pressed |
The updated tabulator()
HTML widget
Set editor
set_editor( widget, columns, editor = c("input", "textarea", "number", "range", "tickCross", "star", "progress", "date", "time", "datetime", "list"), validator = NULL, ... )
set_editor( widget, columns, editor = c("input", "textarea", "number", "range", "tickCross", "star", "progress", "date", "time", "datetime", "list"), validator = NULL, ... )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
editor |
(character): The editor type. |
validator |
(character vector): One or more validators to validate user input. |
... |
Optional editor parameters depending on the selected editor. |
The updated tabulator()
HTML widget
https://tabulator.info/docs/6.2/edit for available editors
https://tabulator.info/docs/6.2/validate for available validators
setup <- tabulator_options(edit_trigger_event = "click") tabulator(iris[, c(2, 5)], setup) |> set_editor( column = "Species", editor = "list", values_lookup = "active", clearable = TRUE, autocomplete = TRUE ) |> set_editor( column = "Sepal_Width", editor = "number", min = 0, max = 10, step = 0.1, validator = c("min:0", "max:10") )
setup <- tabulator_options(edit_trigger_event = "click") tabulator(iris[, c(2, 5)], setup) |> set_editor( column = "Species", editor = "list", values_lookup = "active", clearable = TRUE, autocomplete = TRUE ) |> set_editor( column = "Sepal_Width", editor = "number", min = 0, max = 10, step = 0.1, validator = c("min:0", "max:10") )
Set color formatter
set_formatter_color(widget, columns)
set_formatter_color(widget, columns)
widget |
A |
columns |
The names of the columns the formatter is applied to. |
The updated tabulator()
HTML widget
data <- data.frame( Label = c("R", "G", "B"), Color = c("red", "green", "blue") ) tabulator(data, width = 200) |> set_formatter_color("Color")
data <- data.frame( Label = c("R", "G", "B"), Color = c("red", "green", "blue") ) tabulator(data, width = 200) |> set_formatter_color("Color")
Set datetime formatter
set_formatter_datetime( widget, columns, input_format = "yyyy-MM-dd hh:ss:mm", output_format = "yy/MM/dd", invalid_placeholder = "(invalid datetime)", timezone = NA, hoz_align = "left" )
set_formatter_datetime( widget, columns, input_format = "yyyy-MM-dd hh:ss:mm", output_format = "yy/MM/dd", invalid_placeholder = "(invalid datetime)", timezone = NA, hoz_align = "left" )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
input_format |
(character): The datetime input format. |
output_format |
(character): The datetime output format. |
invalid_placeholder |
(character): The value to be displayed if an invalid datetime is provided. |
timezone |
(character): The timezone of the datetime. |
hoz_align |
(character): The horizontal alignment of the column. |
To use this formatter, you need to include
the luxon HTML dependency with tabulator(..., luxon = TRUE)
.
The updated tabulator()
HTML widget
data <- data.frame( Person = c("Franz", "Ferdinand"), Birthday = c( "2024-12-06 22:00:10", "2023-06-07 14:12:45" ) ) tabulator(data, luxon = TRUE) |> set_formatter_datetime("Birthday", output_format = "dd.MM.yyyy")
data <- data.frame( Person = c("Franz", "Ferdinand"), Birthday = c( "2024-12-06 22:00:10", "2023-06-07 14:12:45" ) ) tabulator(data, luxon = TRUE) |> set_formatter_datetime("Birthday", output_format = "dd.MM.yyyy")
Set HTML formatter
set_formatter_html(widget, columns, hoz_align = c("left", "center", "right"))
set_formatter_html(widget, columns, hoz_align = c("left", "center", "right"))
widget |
A |
columns |
The names of the columns the formatter is applied to. |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( id = c(1, 2, 3, 4, 5, 6, 7), text_style = c( "<i>Italic</i>", "<b>Bold</b>", "<span style='color: green'>Green</span>", "<del>Deleted</del>", "<small>Small</small>", "H<sub>2</sub>O", "x<sup>2</sup>" ) ) tabulator(data, width = 400) |> set_formatter_html("text_style")
data <- data.frame( id = c(1, 2, 3, 4, 5, 6, 7), text_style = c( "<i>Italic</i>", "<b>Bold</b>", "<span style='color: green'>Green</span>", "<del>Deleted</del>", "<small>Small</small>", "H<sub>2</sub>O", "x<sup>2</sup>" ) ) tabulator(data, width = 400) |> set_formatter_html("text_style")
Set image formatter
set_formatter_image( widget, columns, height = "50px", width = "50px", url_prefix = NULL, url_suffix = NULL, hoz_align = "center" )
set_formatter_image( widget, columns, height = "50px", width = "50px", url_prefix = NULL, url_suffix = NULL, hoz_align = "center" )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
height |
(character): A CSS value for the height of the image. |
width |
(character): A CSS value for the width of the image. |
url_prefix |
(character): String to add to the start of the cell value when generating the image src url. |
url_suffix |
(character): String to add to the end of the cell value when generating the image src url. |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
image_url <- "https://picsum.photos/id/" image_size <- 100 image_data <- data.frame( image = c(88, 98, 102, 201), label = c("Pic No. 88", "Pic No. 98", "Pic No. 102", "Pic No 201") ) tabulator(image_data, tabulator_options(height = "400px")) |> set_formatter_image( "image", height = image_size, width = image_size, url_prefix = image_url, url_suffix = glue::glue("/{image_size}"), hoz_align = "left" )
image_url <- "https://picsum.photos/id/" image_size <- 100 image_data <- data.frame( image = c(88, 98, 102, 201), label = c("Pic No. 88", "Pic No. 98", "Pic No. 102", "Pic No 201") ) tabulator(image_data, tabulator_options(height = "400px")) |> set_formatter_image( "image", height = image_size, width = image_size, url_prefix = image_url, url_suffix = glue::glue("/{image_size}"), hoz_align = "left" )
Set link formatter
set_formatter_link( widget, columns, label_field = NULL, url_prefix = NULL, url = NULL, target = "_blank", hoz_align = "left" )
set_formatter_link( widget, columns, label_field = NULL, url_prefix = NULL, url = NULL, target = "_blank", hoz_align = "left" )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
label_field |
(character): Column to be used as label for the link. |
url_prefix |
(character): Prefix to add to the URL value. |
url |
(JavaScript function): A JavaScript function that return the URL value. The cell is passed to the function as its first argument. Use JS to pass JS code. |
target |
(character): Target attribute of the anchor tag. |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( label = c("This is a link", "This is another link"), link = c("https://eoda.de", "https://eoda.de/data-science"), link2 = c("eoda.de", "github.com"), link3 = c("guinan", "data-science") ) js_func <- "(cell) => `https://eoda.de/${cell.getValue()}`" tabulator(data) |> set_formatter_link("link", label_field = "label") |> set_formatter_link("link2", url_prefix = "https://") |> set_formatter_link("link3", url = htmlwidgets::JS(js_func), label_field = "label")
data <- data.frame( label = c("This is a link", "This is another link"), link = c("https://eoda.de", "https://eoda.de/data-science"), link2 = c("eoda.de", "github.com"), link3 = c("guinan", "data-science") ) js_func <- "(cell) => `https://eoda.de/${cell.getValue()}`" tabulator(data) |> set_formatter_link("link", label_field = "label") |> set_formatter_link("link2", url_prefix = "https://") |> set_formatter_link("link3", url = htmlwidgets::JS(js_func), label_field = "label")
Set money formatter
set_formatter_money( widget, columns, decimal = c(",", "."), thousand = c(".", ","), symbol = "$", symbol_after = "p", negative_sign = "-", precision = FALSE, hoz_align = "left" )
set_formatter_money( widget, columns, decimal = c(",", "."), thousand = c(".", ","), symbol = "$", symbol_after = "p", negative_sign = "-", precision = FALSE, hoz_align = "left" )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
decimal |
(character): Symbol to represent the decimal point. |
thousand |
(character, bool): Symbol to represent the thousands separator.
Set to |
symbol |
(character): The currency symbol. |
symbol_after |
(bool): Whether to put the symbol after the number. |
negative_sign |
(character, bool): The sign to show in front of the number.
Set to |
precision |
(integer, bool): The number of decimals to display.
Set to |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( Account_Number = c( 123456, 345667, 234567, 234566 ), Account_Balance = c(100, -50, 200.30, -21.5) ) tabulator(data) |> set_formatter_money( "Account_Balance", symbol = "\U20AC", symbol_after = FALSE, hoz_align = "right" )
data <- data.frame( Account_Number = c( 123456, 345667, 234567, 234566 ), Account_Balance = c(100, -50, 200.30, -21.5) ) tabulator(data) |> set_formatter_money( "Account_Balance", symbol = "\U20AC", symbol_after = FALSE, hoz_align = "right" )
Set plain text formatter
set_formatter_plaintext(widget, columns, hoz_align = "left")
set_formatter_plaintext(widget, columns, hoz_align = "left")
widget |
A |
columns |
The names of the columns the formatter is applied to. |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
tabulator(iris) |> set_formatter_plaintext("Species", hoz_align = "right")
tabulator(iris) |> set_formatter_plaintext("Species", hoz_align = "right")
Set progress formatter
set_formatter_progress( widget, columns, min = NA, max = NA, color = c("yellow", "orange", "red"), legend = NA, legend_color = "#000000", legend_align = c("center", "left", "right", "justify"), hoz_align = "left" )
set_formatter_progress( widget, columns, min = NA, max = NA, color = c("yellow", "orange", "red"), legend = NA, legend_color = "#000000", legend_align = c("center", "left", "right", "justify"), hoz_align = "left" )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
min |
(numeric): The minimum value for progress bar.
If set to |
max |
(numeric): The maximum value for progress bar.
If set to |
color |
(character): Either a single color or a vector of colors |
legend |
(character, |
legend_color |
(character): The text color of the legend. |
legend_align |
(character): The text alignment of the legend. |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( id = 1:6, value = c(10, 0, 100, 20, 40, 60), value2 = c(10, 0, 100, 20, 40, 60), value3 = c(10, 0, 100, 20, 40, 60) ) js_func <- htmlwidgets::JS("(cellValue) => `${cellValue}%`") tabulator(data) |> set_formatter_progress("value") |> set_formatter_progress("value2", legend = TRUE, legend_align = "left") |> set_formatter_progress("value3", legend = js_func, legend_align = "right")
data <- data.frame( id = 1:6, value = c(10, 0, 100, 20, 40, 60), value2 = c(10, 0, 100, 20, 40, 60), value3 = c(10, 0, 100, 20, 40, 60) ) js_func <- htmlwidgets::JS("(cellValue) => `${cellValue}%`") tabulator(data) |> set_formatter_progress("value") |> set_formatter_progress("value2", legend = TRUE, legend_align = "left") |> set_formatter_progress("value3", legend = js_func, legend_align = "right")
Set star rating formatter
set_formatter_star(widget, columns, number_of_stars = NA, hoz_align = "center")
set_formatter_star(widget, columns, number_of_stars = NA, hoz_align = "center")
widget |
A |
columns |
The names of the columns the formatter is applied to. |
number_of_stars |
The maximum number of stars to be displayed.
If set to |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( Passengers = c("Hans", "Franz", "Ferdinand", "Julia"), PassengerClass = c(1, 2, 1, 3) ) tabulator(data, width = 200) |> set_formatter_star("PassengerClass", number_of_stars = max(data$PassengerClass))
data <- data.frame( Passengers = c("Hans", "Franz", "Ferdinand", "Julia"), PassengerClass = c(1, 2, 1, 3) ) tabulator(data, width = 200) |> set_formatter_star("PassengerClass", number_of_stars = max(data$PassengerClass))
Set text area formatter
set_formatter_textarea(widget, columns, hoz_align = "left")
set_formatter_textarea(widget, columns, hoz_align = "left")
widget |
A |
columns |
The names of the columns the formatter is applied to. |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( id = c(1, 2), txt = c( "This\nis\nsome\ntext\nwith\nmultiple\nline\nbreaks", "- R\n- Python\n- Julia" ) ) tabulator(data, width = 200) |> set_formatter_textarea("txt")
data <- data.frame( id = c(1, 2), txt = c( "This\nis\nsome\ntext\nwith\nmultiple\nline\nbreaks", "- R\n- Python\n- Julia" ) ) tabulator(data, width = 200) |> set_formatter_textarea("txt")
Set tick cross formatter
set_formatter_tick_cross(widget, columns, hoz_align = "center")
set_formatter_tick_cross(widget, columns, hoz_align = "center")
widget |
A |
columns |
The names of the columns the formatter is applied to. |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( Artist = c("Art Blackey", "Nirvana", "Bob Marley"), Grunge = c(0, 1, 0), Jazz = c(1, 0, 0), Reggae = c(0, 0, 1) ) tabulator(data, width = 400) |> set_formatter_tick_cross("Grunge") |> set_formatter_tick_cross("Jazz") |> set_formatter_tick_cross("Reggae")
data <- data.frame( Artist = c("Art Blackey", "Nirvana", "Bob Marley"), Grunge = c(0, 1, 0), Jazz = c(1, 0, 0), Reggae = c(0, 0, 1) ) tabulator(data, width = 400) |> set_formatter_tick_cross("Grunge") |> set_formatter_tick_cross("Jazz") |> set_formatter_tick_cross("Reggae")
Set toggle switch formatter
set_formatter_toggle_switch( widget, columns, size = 20, on_value = "on", off_value = "off", on_truthy = FALSE, on_color = "green", off_color = "red", clickable = TRUE )
set_formatter_toggle_switch( widget, columns, size = 20, on_value = "on", off_value = "off", on_truthy = FALSE, on_color = "green", off_color = "red", clickable = TRUE )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
size |
(numeric): The size of the switch in pixels. |
on_value |
(character): The value of the cell for the switch to be on. |
off_value |
(character) The value of the cell for the switch to be off. |
on_truthy |
(bool): Whether to show the switch as on if the value of the cell is truthy. |
on_color |
(character): The color of the switch if it is on. |
off_color |
(character): The color of the switch if it is off. |
clickable |
(bool): Enable switch functionality to toggle the cell value on click. |
The updated tabulator()
HTML widget
data <- data.frame( Language = c("R", "Python", "Julia"), Available = c("yes", "yes", "no") ) tabulator(data) |> set_formatter_toggle_switch("Available", on_value = "yes", off_value = "no")
data <- data.frame( Language = c("R", "Python", "Julia"), Available = c("yes", "yes", "no") ) tabulator(data) |> set_formatter_toggle_switch("Available", on_value = "yes", off_value = "no")
Set traffic light formatter
set_formatter_traffic_light( widget, columns, min = NA, max = NA, color = c("green", "orange", "red"), hoz_align = "center" )
set_formatter_traffic_light( widget, columns, min = NA, max = NA, color = c("green", "orange", "red"), hoz_align = "center" )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
min |
(numeric): The minimum value for progress bar.
If set to |
max |
(numeric): The maximum value for progress bar.
If set to |
color |
(character): Either a single color or a vector of colors |
hoz_align |
(character): The horizontal alignment of the column. |
The updated tabulator()
HTML widget
data <- data.frame( label = 1:10, value = 1:10 ) tabulator(data, width = 200) |> set_formatter_traffic_light("value") |> set_formatter_plaintext("label", hoz_align = "center")
data <- data.frame( label = 1:10, value = 1:10 ) tabulator(data, width = 200) |> set_formatter_traffic_light("value") |> set_formatter_plaintext("label", hoz_align = "center")
Set header filter
set_header_filter( widget, columns, type = c("input", "number", "list", "tickCross"), func = c("like", "=", ">", ">=", "<", "<="), values_lookup = TRUE, clearable = TRUE, placeholder = NULL )
set_header_filter( widget, columns, type = c("input", "number", "list", "tickCross"), func = c("like", "=", ">", ">=", "<", "<="), values_lookup = TRUE, clearable = TRUE, placeholder = NULL )
widget |
A |
columns |
The names of the columns the formatter is applied to. |
type |
(character): The type of the filter. |
func |
(character): The filter function. |
values_lookup |
(bool): Whether to use unique column values for the list filter. |
clearable |
(bool): Whether to display a cross to clear the filter. |
placeholder |
(character): Text that is displayed when no filter is set. |
The updated tabulator()
HTML widget
data <- data.frame( age = c(10, 20, 40), first_name = c("Franz", "Ferdinand", "Julia"), last_name = c("Young", "Bowie", "Blackey") ) tabulator(data) |> set_header_filter("age", type = NULL, func = "<=", placeholder = "max age") |> set_header_filter("first_name", placeholder = "Fran") |> set_header_filter("last_name", type = "list")
data <- data.frame( age = c(10, 20, 40), first_name = c("Franz", "Ferdinand", "Julia"), last_name = c("Young", "Bowie", "Blackey") ) tabulator(data) |> set_header_filter("age", type = NULL, func = "<=", placeholder = "max age") |> set_header_filter("first_name", placeholder = "Fran") |> set_header_filter("last_name", type = "list")
Set multi column header
set_multi_column_header(widget, multi_columns)
set_multi_column_header(widget, multi_columns)
widget |
A |
multi_columns |
(list): Multi column definitions. |
The updated tabulator()
HTML widget
multi_columns <- list( Sepal = c("Sepal_Length", "Sepal_Width"), Petal = c("Petal_Length", "Petal_Width") ) tabulator(iris) |> set_multi_column_header(multi_columns)
multi_columns <- list( Sepal = c("Sepal_Length", "Sepal_Width"), Petal = c("Petal_Length", "Petal_Width") ) tabulator(iris) |> set_multi_column_header(multi_columns)
Set group by options
set_options_group_by( widget, group_by, group_start_open = TRUE, group_toggle_element = "header", ... )
set_options_group_by( widget, group_by, group_start_open = TRUE, group_toggle_element = "header", ... )
widget |
A |
group_by |
(character vector): Field to group rows by. Pass multiple values for multi level grouping. |
group_start_open |
(bool vector): Open state of groups when grouping is enabled.
The length of the vector depends on the number of levels set with |
group_toggle_element |
(character, bool): One of |
... |
Further options. |
The updated tabulator()
HTML widget
tabulator(iris) |> set_options_group_by("Species", group_start_open = FALSE)
tabulator(iris) |> set_options_group_by("Species", group_start_open = FALSE)
Set pagination options
set_options_pagination( widget, pagination = TRUE, pagination_size = 10, pagination_size_selector = FALSE, pagination_add_row = c("page", "table"), ... )
set_options_pagination( widget, pagination = TRUE, pagination_size = 10, pagination_size_selector = FALSE, pagination_add_row = c("page", "table"), ... )
widget |
A |
pagination |
(bool): Whether to enable pagination. |
pagination_size |
(integer): Number of rows on each page. |
pagination_size_selector |
(list): Add pagination size selector. |
pagination_add_row |
(character): Where to add rows to the table when pagination is enabled. |
... |
Further options. |
The updated tabulator()
HTML widget
tabulator(iris) |> set_options_pagination(pagination_size_selector = c(10, 20, 50))
tabulator(iris) |> set_options_pagination(pagination_size_selector = c(10, 20, 50))
Set tooltip
set_tooltip(widget, columns)
set_tooltip(widget, columns)
widget |
A |
columns |
The names of the columns the formatter is applied to. |
The updated tabulator()
HTML widget
tabulator(airquality) |> set_formatter_traffic_light("Ozone") |> set_tooltip("Ozone")
tabulator(airquality) |> set_formatter_traffic_light("Ozone") |> set_tooltip("Ozone")
tabulator()
HTML widgetSpreadsheet definition for tabulator()
HTML widget
spreadsheet_def(title, key = NULL, data = NULL)
spreadsheet_def(title, key = NULL, data = NULL)
title |
Name of the spreadsheet. |
key |
Unique key of the spreadsheet. |
data |
Initial data of the spreadsheet.
Set to |
list with spreadsheet options to be used as a sheet of the
spreadsheet_sheets
parameter in tabulator_options()
setup <- tabulator_options( spreadsheet = TRUE, spreadsheet_sheets = list( spreadsheet_def( title = "First", data = list(c(1, 2, 3)) ), spreadsheet_def( title = "Second", data = list(c(4, 5, 6)) ) ), spreadsheet_sheet_tabs = TRUE ) tabulator(data = NULL, setup, theme = "midnight")
setup <- tabulator_options( spreadsheet = TRUE, spreadsheet_sheets = list( spreadsheet_def( title = "First", data = list(c(1, 2, 3)) ), spreadsheet_def( title = "Second", data = list(c(4, 5, 6)) ) ), spreadsheet_sheet_tabs = TRUE ) tabulator(data = NULL, setup, theme = "midnight")
HTML widget to work with tabular data
tabulator( data, options = tabulator_options(), editable = FALSE, luxon = FALSE, sheetjs = FALSE, theme = c("default", "midnight", "modern", "simple", "site", "bootstrap3", "bootstrap4", "bootstrap5", "bulma", "materialize", "semanticui"), col_select = NULL, width = NULL, height = NULL, element_id = NULL, ... )
tabulator( data, options = tabulator_options(), editable = FALSE, luxon = FALSE, sheetjs = FALSE, theme = c("default", "midnight", "modern", "simple", "site", "bootstrap3", "bootstrap4", "bootstrap5", "bulma", "materialize", "semanticui"), col_select = NULL, width = NULL, height = NULL, element_id = NULL, ... )
data |
(data.frame, character or list): In spreadsheet mode data needs to be a list or |
options |
List of setup options. Defaults to |
editable |
Whether the table is editable. |
luxon |
Whether to add luxon HTML dependency,
which is required for |
sheetjs |
Whether to add sheetjs HTML dependency,
which is required for |
theme |
Name of the theme to be applied to the table. |
col_select |
Passed to |
width , height
|
Output size. |
element_id |
Unique ID of the widget element. |
... |
Named arguments that are appended to the |
Dots in column names are replaced by underscores.
A HTML widget
tabulatorOutput()
for use within Shiny apps
setup <- tabulator_options( spreadsheet = TRUE, spreadsheet_sheets = list( spreadsheet_def( title = "First", data = list(c(1, 2, 3)) ), spreadsheet_def( title = "Second", data = list(c(4, 5, 6)) ) ), spreadsheet_sheet_tabs = TRUE ) tabulator(data = NULL, setup, theme = "midnight")
setup <- tabulator_options( spreadsheet = TRUE, spreadsheet_sheets = list( spreadsheet_def( title = "First", data = list(c(1, 2, 3)) ), spreadsheet_def( title = "Second", data = list(c(4, 5, 6)) ) ), spreadsheet_sheet_tabs = TRUE ) tabulator(data = NULL, setup, theme = "midnight")
tabulator()
HTML widgetSetup options for tabulator()
HTML widget
tabulator_options( height = "311px", history = FALSE, columns = NULL, layout = c("fitColumns", "fitData", "fitDataFill", "fitDataStretch", "fitDataTable"), responsive_layout = FALSE, movable_columns = FALSE, header_visible = TRUE, row_height = NULL, add_row_pos = c("bottom", "top"), movable_rows = FALSE, resizable_rows = FALSE, frozen_rows = NULL, index = "id", group_by = NULL, group_start_open = TRUE, group_toggle_element = NULL, edit_trigger_event = c("dblclick", "click", "focus"), selectable_rows = "highlight", pagination = FALSE, pagination_size = 10, pagination_size_selector = FALSE, pagination_add_row = c("page", "table"), spreadsheet = FALSE, spreadsheet_rows = NULL, spreadsheet_columns = NULL, spreadsheet_column_definition = NULL, spreadsheet_sheets = NULL, spreadsheet_sheet_tabs = NULL, ... )
tabulator_options( height = "311px", history = FALSE, columns = NULL, layout = c("fitColumns", "fitData", "fitDataFill", "fitDataStretch", "fitDataTable"), responsive_layout = FALSE, movable_columns = FALSE, header_visible = TRUE, row_height = NULL, add_row_pos = c("bottom", "top"), movable_rows = FALSE, resizable_rows = FALSE, frozen_rows = NULL, index = "id", group_by = NULL, group_start_open = TRUE, group_toggle_element = NULL, edit_trigger_event = c("dblclick", "click", "focus"), selectable_rows = "highlight", pagination = FALSE, pagination_size = 10, pagination_size_selector = FALSE, pagination_add_row = c("page", "table"), spreadsheet = FALSE, spreadsheet_rows = NULL, spreadsheet_columns = NULL, spreadsheet_column_definition = NULL, spreadsheet_sheets = NULL, spreadsheet_sheet_tabs = NULL, ... )
height |
(character) The height of the table in pixels. |
history |
(bool): Enable user interaction history functionality. |
columns |
(list): Column definitions.
If set to |
layout |
(character): Layout mode of the table columns. |
responsive_layout |
(bool): Automatically hide and show columns to fit the width of the Tabulator element. |
movable_columns |
(bool): Allow users to move and reorder rows. |
header_visible |
(bool): Whether header is visible. |
row_height |
(numeric): A fixed height of the rows. |
add_row_pos |
(character): The table position where new rows are added. |
movable_rows |
(bool): Allow users to move and reorder rows. |
resizable_rows |
(bool): Allow user to resize rows. |
frozen_rows |
(numeric): Number of frozen rows. |
index |
(character): Field to be used as the unique index for each row. |
group_by |
(character vector): Field to group rows by. Pass multiple values for multi level grouping. |
group_start_open |
(bool vector): Open state of groups when grouping is enabled.
The length of the vector depends on the number of levels set with |
group_toggle_element |
(character, bool): One of |
edit_trigger_event |
(character): Event that triggers a cell edit. |
selectable_rows |
(character, bool, integer) Set to |
pagination |
(bool): Whether to enable pagination. |
pagination_size |
(integer): Number of rows on each page. |
pagination_size_selector |
(list): Add pagination size selector. |
pagination_add_row |
(character): Where to add rows to the table when pagination is enabled. |
spreadsheet |
(bool): Whether to enable spreadsheet mode. |
spreadsheet_rows |
(integer): Number of spreadsheet rows. |
spreadsheet_columns |
(integer): Number of spreadsheet columns. |
spreadsheet_column_definition |
Column definition used for all columns in the sheet. |
spreadsheet_sheets |
(list): List of sheet definitions. |
spreadsheet_sheet_tabs |
(bool): Whether to show sheet tabs in the footer. |
... |
Further options. |
list with setup options to be used as options
parameter in tabulator()
https://tabulator.info/docs/6.2/options for a complete list of available options
setup <- tabulator_options( group_by = "Species", pagination = TRUE, pagination_size = 10, pagination_size_selector = c(10, 20, 50), movable_columns = TRUE, movable_rows = TRUE ) tabulator(iris, setup)
setup <- tabulator_options( group_by = "Species", pagination = TRUE, pagination_size = 10, pagination_size_selector = c(10, 20, 50), movable_columns = TRUE, movable_rows = TRUE ) tabulator(iris, setup)
tabulator()
HTML widgetContext object to update a tabulator()
HTML widget
tabulatorContext(output_id, session = shiny::getDefaultReactiveDomain())
tabulatorContext(output_id, session = shiny::getDefaultReactiveDomain())
output_id |
A tabulator output id set with |
session |
A shiny session object. |
Makes it possible to update your tabulator()
HTML widget in Shiny apps.
A context object that can be used to interact with a tabulator()
HTML widget
tabulatorContext("table") |> trigger_download("csv")
tabulatorContext("table") |> trigger_download("csv")
Titanic data set
titanic(col_select = NULL)
titanic(col_select = NULL)
col_select |
(character vector): Columns to select. |
data frame
titanic(c("PassengerId", "Age", "Pclass", "Fare")) |> head()
titanic(c("PassengerId", "Age", "Pclass", "Fare")) |> head()
Download table data
trigger_download(ctx, type = c("csv", "json", "xlsx"), file_name = NULL)
trigger_download(ctx, type = c("csv", "json", "xlsx"), file_name = NULL)
ctx |
A |
type |
File format. |
file_name |
File name. Set to |
If you want to support xlsx
downloads, you need to include
the sheetjs HTML dependency with tabulator(..., sheetjs = TRUE)
.
A tabulatorContext()
object
tabulatorContext("table") |> trigger_download("csv", "table-data.csv")
tabulatorContext("table") |> trigger_download("csv", "table-data.csv")
Submit data to R
trigger_get_data(ctx)
trigger_get_data(ctx)
ctx |
A |
A tabulatorContext()
object
tabulatorContext("table") |> trigger_get_data()
tabulatorContext("table") |> trigger_get_data()
Submit sheet data to R
trigger_get_sheet_data(ctx)
trigger_get_sheet_data(ctx)
ctx |
A |
A tabulatorContext()
object
tabulatorContext("table") |> trigger_get_sheet_data()
tabulatorContext("table") |> trigger_get_sheet_data()
Undo changes
undo(ctx)
undo(ctx)
ctx |
A |
A tabulatorContext()
object
tabulatorContext("table") |> undo()
tabulatorContext("table") |> undo()