Type: Package
Title: R Bindings for 'Tabulator JS'
Version: 0.1.2
Date: 2024-09-22
Maintainer: Stefan Kuethe <crazycapivara@gmail.com>
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.
URL: https://github.com/eodaGmbH/rtabulator https://eodagmbh.github.io/rtabulator/
BugReports: https://github.com/eodaGmbH/rtabulator/issues
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
Imports: glue, htmltools, htmlwidgets, purrr, readr, shiny
Config/Needs/website: rmarkdown
NeedsCompilation: no
Packaged: 2024-09-22 12:32:14 UTC; stefan
Author: Stefan Kuethe [aut, cre, cph], Nico Friess [aut], Oli Folkerd [cph] (Author of included tabulator.js library)
Repository: CRAN
Date/Publication: 2024-09-23 13:40:04 UTC

Add row to table

Description

Add row to table

Usage

add_row(ctx, row = NULL)

Arguments

ctx

A tabulatorContext() object.

row

(list): row data or NULL to add an empty row

Value

A tabulatorContext() object

Examples


tabulatorContext("table") |>
  add_row()


Delete selected rows from table

Description

Delete selected rows from table

Usage

delete_selected_rows(ctx)

Arguments

ctx

A tabulatorContext() object.

Value

A tabulatorContext() object

Examples


tabulatorContext("table") |>
  delete_selected_rows()


Apply a column setter function to multiple columns

Description

Apply a column setter function to multiple columns

Usage

for_each_col(widget, columns = NULL, .f, ...)

Arguments

widget

A tabulator() HTML widget.

columns

(character vector): The columns the column setter function (.f) is applied to. If set to NULL, it is applied to all columns.

.f

(function): The column setter function that updates the column settings.

...

Arguments that are passed to .f.

Value

The updated tabulator() HTML widget

Examples

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 = "<=")

Redo changes

Description

Redo changes

Usage

redo(ctx)

Arguments

ctx

A tabulatorContext() object.

Value

A tabulatorContext() object

Examples


tabulatorContext("table") |>
  redo()


Shiny bindings for rtabulator

Description

Output and render functions for using rtabulator within Shiny applications and interactive Rmd documents.

Usage

tabulatorOutput(outputId, width = "100%", height = "400px")

renderTabulator(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

output variable to read from

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

expr

An expression that generates a rtabulator

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Value

Components for use inside a Shiny app.


Set calculation

Description

Set calculation

Usage

set_calculation(
  widget,
  column,
  func = c("avg", "max", "min", "sum", "count", "unique"),
  precision = 2,
  pos = c("top", "bottom")
)

Arguments

widget

A tabulator() HTML widget.

column

(character): The column the func is applied to.

func

(character): The calculation function to be applied to the values of the column.

precision

(integer) The number of decimals to display. Set to FALSE to display all decimals.

pos

(character): Position at which calculated values are displayed.

Value

The updated tabulator() HTML widget

Examples

tabulator(iris) |>
  set_calculation("Sepal_Length", "avg")

Set column defaults

Description

Set column defaults

Usage

set_column_defaults(
  widget,
  editor = FALSE,
  header_filter = FALSE,
  header_sort = TRUE,
  tooltip = TRUE,
  width = NULL,
  ...
)

Arguments

widget

A tabulator() HTML widget.

editor

(character, bool): One of "input" or "number". If set to FALSE cells are not editable.

header_filter

(character, bool): One of "input" or "number". Set to FALSE to disable header filters.

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.

Value

The updated tabulator() HTML widget

See Also

https://tabulator.info/docs/6.2/columns#defaults

Examples

tabulator(iris, theme = "simple") |>
  set_column_defaults(
    header_filter = TRUE,
    header_sort = FALSE,
    tooltip = TRUE
  )

Set editor

Description

Set editor

Usage

set_editor(
  widget,
  column,
  editor = c("input", "textarea", "number", "range", "tickCross", "star", "progress",
    "date", "time", "datetime", "list"),
  validator = NULL,
  ...
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column 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.

Value

The updated tabulator() HTML widget

See Also

Examples

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

Description

Set color formatter

Usage

set_formatter_color(widget, column)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

Value

The updated tabulator() HTML widget

Examples

data <- data.frame(
  Label = c("R", "G", "B"),
  Color = c("red", "green", "blue")
)

tabulator(data, width = 200) |>
  set_formatter_color("Color")

Set datetime formatter

Description

Set datetime formatter

Usage

set_formatter_datetime(
  widget,
  column,
  input_format = "yyyy-MM-dd hh:ss:mm",
  output_format = "yy/MM/dd",
  invalid_placeholder = "(invalid datetime)",
  timezone = NA,
  hoz_align = "left"
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column 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.

Details

To use this formatter, you need to include the luxon HTML dependency with tabulator(..., luxon = TRUE).

Value

The updated tabulator() HTML widget

Examples

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

Description

Set HTML formatter

Usage

set_formatter_html(widget, column, hoz_align = c("left", "center", "right"))

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set image formatter

Usage

set_formatter_image(
  widget,
  column,
  height = "50px",
  width = "50px",
  url_prefix = NULL,
  url_suffix = NULL,
  hoz_align = "center"
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column 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.

Value

The updated tabulator() HTML widget

Examples

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"
  )

Description

Set link formatter

Usage

set_formatter_link(
  widget,
  column,
  label_field = NULL,
  url_prefix = NULL,
  url = NULL,
  target = "_blank",
  hoz_align = "left"
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column 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.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set money formatter

Usage

set_formatter_money(
  widget,
  column,
  decimal = c(",", "."),
  thousand = c(".", ","),
  symbol = "$",
  symbol_after = "p",
  negative_sign = "-",
  precision = FALSE,
  hoz_align = "left"
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

decimal

(character): Symbol to represent the decimal point.

thousand

(character, bool): Symbol to represent the thousands separator. Set to FALSE to disable the separator.

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 TRUE causes negative numbers to be enclosed in brackets (123.45), which is the standard style for negative numbers in accounting.

precision

(integer, bool): The number of decimals to display. Set to FALSE to display all decimals that are provided.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set plain text formatter

Usage

set_formatter_plaintext(widget, column, hoz_align = "left")

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

tabulator(iris) |>
  set_formatter_plaintext("Species", hoz_align = "right")

Set progress formatter

Description

Set progress formatter

Usage

set_formatter_progress(
  widget,
  column,
  min = NA,
  max = NA,
  color = c("yellow", "orange", "red"),
  legend = NA,
  legend_color = "#000000",
  legend_align = c("center", "left", "right", "justify"),
  hoz_align = "left"
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

min

(numeric): The minimum value for progress bar. If set to NA, the minimum value of the column is used.

max

(numeric): The maximum value for progress bar. If set to NA, the maximum value of the column is used.

color

(character): Either a single color or a vector of colors

legend

(character, TRUE, JavaScript function): If set to TRUE, the value of the cell is displayed. Set to NA to display no value at all. Use JS to pass a JavaScript function as legend. In this case, the cell value is passed to the function as its first argument.

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.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set star rating formatter

Usage

set_formatter_star(widget, column, number_of_stars = NA, hoz_align = "center")

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

number_of_stars

The maximum number of stars to be displayed. If set to NA, the maximum value of the column is used.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set text area formatter

Usage

set_formatter_textarea(widget, column, hoz_align = "left")

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set tick cross formatter

Usage

set_formatter_tick_cross(widget, column, hoz_align = "center")

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set toggle switch formatter

Usage

set_formatter_toggle_switch(
  widget,
  column,
  size = 20,
  on_value = "on",
  off_value = "off",
  on_truthy = FALSE,
  on_color = "green",
  off_color = "red",
  clickable = TRUE
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column 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.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set traffic light formatter

Usage

set_formatter_traffic_light(
  widget,
  column,
  min = NA,
  max = NA,
  color = c("green", "orange", "red"),
  hoz_align = "center"
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

min

(numeric): The minimum value for progress bar. If set to NA, the minimum value of the column is used.

max

(numeric): The maximum value for progress bar. If set to NA, the maximum value of the column is used.

color

(character): Either a single color or a vector of colors

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set header filter

Usage

set_header_filter(
  widget,
  column,
  type = c("input", "number", "list", "tickCross"),
  func = c("like", "=", ">", ">=", "<", "<="),
  values_lookup = TRUE,
  clearable = TRUE,
  placeholder = NULL
)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column 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.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set multi column header

Usage

set_multi_column_header(widget, multi_columns)

Arguments

widget

A tabulator() HTML widget.

multi_columns

(list): Multi column definitions.

Value

The updated tabulator() HTML widget

Examples

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

Description

Set group by options

Usage

set_options_group_by(
  widget,
  group_by,
  group_start_open = TRUE,
  group_toggle_element = "header",
  ...
)

Arguments

widget

A tabulator() HTML widget.

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_by.

group_toggle_element

(character, bool): One of arrow or header. Set to FALSE to disable toggling at all.

...

Further options.

Value

The updated tabulator() HTML widget

Examples

tabulator(iris) |>
  set_options_group_by("Species", group_start_open = FALSE)

Set pagination options

Description

Set pagination options

Usage

set_options_pagination(
  widget,
  pagination = TRUE,
  pagination_size = 10,
  pagination_size_selector = FALSE,
  pagination_add_row = c("page", "table"),
  ...
)

Arguments

widget

A tabulator() HTML widget.

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.

Value

The updated tabulator() HTML widget

Examples

tabulator(iris) |>
  set_options_pagination(pagination_size_selector = c(10, 20, 50))

Set tooltip

Description

Set tooltip

Usage

set_tooltip(widget, column)

Arguments

widget

A tabulator() HTML widget.

column

The name of the column the formatter is applied to.

Value

The updated tabulator() HTML widget

Examples

tabulator(airquality) |>
  set_formatter_traffic_light("Ozone") |>
  set_tooltip("Ozone")

Spreadsheet definition for tabulator() HTML widget

Description

Spreadsheet definition for tabulator() HTML widget

Usage

spreadsheet_def(title, key = NULL, data = NULL)

Arguments

title

Name of the spreadsheet.

key

Unique key of the spreadsheet.

data

Initial data of the spreadsheet. Set to NULL to create an empty spreadsheet.

Value

list with spreadsheet options to be used as a sheet of the spreadsheet_sheets parameter in tabulator_options()

Examples

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

Description

HTML widget to work with tabular data

Usage

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,
  ...
)

Arguments

data

(data.frame, character or list): In spreadsheet mode data needs to be a list or NULL for an empty spreadsheet.

options

List of setup options. Defaults to tabulator_options().

editable

Whether the table is editable.

luxon

Whether to add luxon HTML dependency, which is required for set_formatter_datetime().

sheetjs

Whether to add sheetjs HTML dependency, which is required for trigger_download() to support downloads of xlsx files.

theme

Name of the theme to be applied to the table.

col_select

Passed to readr::read_csv() if data is a file name.

width, height

Output size.

element_id

Unique ID of the widget element.

...

Named arguments that are appended to the options parameter.

Details

Dots in column names are replaced by underscores.

Value

A HTML widget

See Also

tabulatorOutput() for use within Shiny apps

Examples

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")

Context object to update a tabulator() HTML widget

Description

Context object to update a tabulator() HTML widget

Usage

tabulatorContext(output_id, session = shiny::getDefaultReactiveDomain())

Arguments

output_id

A tabulator output id set with tabulatorOutput().

session

A shiny session object.

Details

Makes it possible to update your tabulator() HTML widget in Shiny apps.

Value

A context object that can be used to interact with a tabulator() HTML widget

Examples


tabulatorContext("table") |>
  trigger_download("csv")


Setup options for tabulator() HTML widget

Description

Setup options for tabulator() HTML widget

Usage

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,
  ...
)

Arguments

height

(character) The height of the table in pixels.

history

(bool): Enable user interaction history functionality.

columns

(list): Column definitions. If set to NULL, definitions are auto generated from table data.

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_by.

group_toggle_element

(character, bool): One of arrow or header. Set to FALSE to disable toggling at all.

edit_trigger_event

(character): Event that triggers a cell edit.

selectable_rows

(character, bool, integer) Set to FALSE to disble row selection. If set to TRUE, you can select as many rows as you want. If set to "highlight", rows are just highlighted but do not change state when clicked. An integer value sets the maximum number of rows that can be selected.

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.

Value

list with setup options to be used as options parameter in tabulator()

See Also

https://tabulator.info/docs/6.2/options for a complete list of available options

Examples

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)

Titanic data set

Description

Titanic data set

Usage

titanic(col_select = NULL)

Arguments

col_select

(character vector): Columns to select.

Value

data frame

Examples


titanic(c("PassengerId", "Age", "Pclass", "Fare")) |>
  head()



Download table data

Description

Download table data

Usage

trigger_download(ctx, type = c("csv", "json", "xlsx"), file_name = NULL)

Arguments

ctx

A tabulatorContext() object.

type

File format.

file_name

File name. Set to "data.{type}" if file_name = NULL.

Details

If you want to support xlsx downloads, you need to include the sheetjs HTML dependency with tabulator(..., sheetjs = TRUE).

Value

A tabulatorContext() object

Examples


tabulatorContext("table") |>
  trigger_download("csv", "table-data.csv")


Submit data to R

Description

Submit data to R

Usage

trigger_get_data(ctx)

Arguments

ctx

A tabulatorContext() object.

Value

A tabulatorContext() object

Examples


tabulatorContext("table") |>
  trigger_get_data()


Submit sheet data to R

Description

Submit sheet data to R

Usage

trigger_get_sheet_data(ctx)

Arguments

ctx

A tabulatorContext() object.

Value

A tabulatorContext() object

Examples


tabulatorContext("table") |>
  trigger_get_sheet_data()


Undo changes

Description

Undo changes

Usage

undo(ctx)

Arguments

ctx

A tabulatorContext() object.

Value

A tabulatorContext() object

Examples


tabulatorContext("table") |>
  undo()