| DataTable | R Documentation |
A virtualised table for data frames or lazy table sources. See data_table().
Widget -> DataTable
paint_statesCursor and scroll changes only repaint.
focusableTables can be focused.
cursor_type"row", "cell" or "none".
show_headerShow the header row?
zebraStripe alternate rows?
row_styleNULL or function(row, data) returning a style for
a data row (row is the original row number or source position).
cell_styleNULL or function(value, row, column) returning a
style for a cell.
frozen_columnsNumber of leading columns that stay visible while the others scroll horizontally.
header_sortClicking a header sorts by that column (click again: descending, then unsorted; Shift+click adds a column)?
editableAllow editing cells (Enter / double click)?
on_editNULL or function(row, column, value) called before a
cell edit is applied; return NULL / TRUE to accept or a message
to reject the edit.
dataThe data frame or source (assigning calls set_data()).
row_countNumber of rows in the current view.
column_namesNames of the data columns.
cursor_rowCursor position in the view (0 = none).
cursor_columnCursor column number (cell cursor; 0 = none).
offset_row, offset_columnScroll offsets (rows / columns).
viewRow numbers or source view positions in display order.
sort_stateNULL or a data frame (column, decreasing) of
the current sort keys.
match_hitNULL or the current search result (position,
row, column).
Widget$add_class()Widget$ancestors()Widget$animate()Widget$arrange_children()Widget$bind()Widget$bind_reactive()Widget$bindings()Widget$blur()Widget$capture_mouse()Widget$child_clip()Widget$clear()Widget$computed_style()Widget$focus()Widget$format()Widget$get_state()Widget$has_class()Widget$invalidate()Widget$invalidate_paint()Widget$is_displayed()Widget$is_enabled()Widget$layout_descend()Widget$layout_differs()Widget$matches()Widget$mount()Widget$on()Widget$post_message()Widget$print()Widget$pseudo_states()Widget$query()Widget$query_one()Widget$release_mouse()Widget$remove()Widget$remove_children()Widget$remove_class()Widget$render()Widget$render_lines()Widget$replace()Widget$run_action()Widget$run_process()Widget$run_worker()Widget$set()Widget$set_interval()Widget$set_state()Widget$set_timeout()Widget$toggle_class()Widget$walk()DataTable$new()Create a table. See data_table().
DataTable$new( data, cursor = "row", columns = NULL, formatters = NULL, row_names = NA, header = TRUE, zebra = FALSE, row_style = NULL, cell_style = NULL, max_column_width = 40L, frozen_columns = 0L, header_sort = FALSE, editable = FALSE, on_edit = NULL, id = NULL, classes = NULL, style = NULL, disabled = FALSE )
dataA data frame, matrix, or table_source().
cursorCursor type.
columnsNamed list of column() options.
formattersNamed list of formatter functions.
row_namesShow row names? NA: only when they are not 1..n.
headerShow the header?
zebraStripe rows?
row_style, cell_styleStyle hooks.
max_column_widthUpper limit for estimated widths.
frozen_columns, header_sort, editable, on_editSee the fields.
id, classes, style, disabledSee Widget.
filtersNamed column filters for filter_columns().
DataTable$default_style()The built-in style.
DataTable$default_style()
DataTable$default_bindings()Navigation keys and Enter.
DataTable$default_bindings()
DataTable$set_data()Replace the data. Resets the view, cursor and scroll.
DataTable$set_data(data)
dataA data frame, matrix, or table_source().
DataTable$refresh()Re-read the source row count and clear cached rows.
DataTable$refresh()
DataTable$close()Explicitly close this table's source resource.
DataTable$close()
DataTable$source_stats()Read structural fetch/cache counters for diagnostics.
DataTable$source_stats()
DataTable$sort()Sort the view by one or more columns (stable; NAs
last). Sorting always starts from the unsorted view (after
filter()), so sort(c("cyl", "mpg")) sorts by cyl, then mpg.
DataTable$sort(by, decreasing = FALSE)
byColumn names or numbers.
decreasingSort in decreasing order? One value, or one per column.
DataTable$clear_sort()Remove the sort order (back to the order before sorting).
DataTable$clear_sort()
DataTable$toggle_sort()Header-click behaviour: sort by a column ascending, then descending, then unsorted.
DataTable$toggle_sort(column, add = FALSE)
columnColumn name or number.
addAdd the column to the existing sort (secondary key)?
DataTable$filter()Show a subset of rows (in the given order), or all rows.
DataTable$filter(rows = NULL)
rowsRow numbers of the data, a logical vector over the rows,
or NULL for all rows.
DataTable$filter_columns()Filter named columns; all predicates are combined with
AND and evaluated in row chunks. A predicate may be a
table_filter() or function(values) logical.
DataTable$filter_columns(filters = NULL)
filtersNamed list by column; NULL clears column filters.
DataTable$move_cursor()Move the cursor (and scroll so it is visible).
DataTable$move_cursor(row = NULL, column = NULL)
rowPosition in the view.
columnColumn name or number (cell cursor).
DataTable$scroll_to_row()Scroll so that a view position is the first visible row.
DataTable$scroll_to_row(row)
rowPosition in the view.
DataTable$selected_row()The data-frame row number or source row key under the cursor (or NA).
DataTable$selected_row()
DataTable$row_data()One data row as a named list.
DataTable$row_data(row)
rowOriginal row number.
DataTable$selected_data()Data for selected view rows, in view order. A single cursor row is returned when no range is selected.
DataTable$selected_data()
DataTable$visible_data()Data in the current viewport, in display order.
DataTable$visible_data()
DataTable$reorder_column()Move a column in the display order.
DataTable$reorder_column(column, to)
columnColumn name or number.
toNew 1-based position in the complete column order.
DataTable$select_range()Select a range of rows by view position.
DataTable$select_range(from, to = from)
from, to1-based positions in the view.
DataTable$copy_selection()Copy selected rows as tab-separated values.
DataTable$copy_selection(headers = TRUE, system = TRUE)
headersInclude column names?
systemAlso write to the system clipboard when supported?
DataTable$goto_row()Jump to a row of the view (and scroll to it).
DataTable$goto_row(row)
rowPosition in the view (1-based).
DataTable$column_width()Width of a column in cells.
DataTable$column_width(column)
columnColumn name or number.
DataTable$set_column_width()Set a column's width (at least 1 cell). Sends
"datatable.column_resized".
DataTable$set_column_width(column, width)
columnColumn name or number.
widthWidth in cells.
DataTable$auto_size_column()Fit a column to its content. Rows are sampled, never all scanned unless asked for, so this is fast for huge tables.
DataTable$auto_size_column(column, rows = c("sample", "visible", "all"))
columnColumn name or number.
rows"sample" (the visible rows plus the first and last 500;
default), "visible" (visible rows only) or "all" (every row of
the view; slow for millions of rows).
DataTable$auto_size_all()Fit every visible column to its content.
DataTable$auto_size_all(rows = c("sample", "visible", "all"))
rowsSee auto_size_column().
DataTable$set_column_visible()Show or hide a column.
DataTable$set_column_visible(column, visible = TRUE)
columnColumn name or number.
visibleTRUE to show, FALSE to hide.
DataTable$column_info()Describe the columns: name, label, width, visible, sortable.
DataTable$column_info()
DataTable$find()Search the formatted cell text and move the cursor to the first match at or after the cursor (reading order, wrapping around). Large tables are scanned in chunks; the data is never converted to one big string matrix.
DataTable$find(query, column = NULL, case_sensitive = FALSE, regex = FALSE)
queryText or regular expression (PCRE).
columnSearch only this column (name or number); NULL: all
visible columns.
case_sensitiveMatch case?
regexIs query a regular expression?
TRUE if there is a match (invisibly).
DataTable$find_next()Go to the next match.
DataTable$find_next()
DataTable$find_previous()Go to the previous match.
DataTable$find_previous()
DataTable$clear_find()Forget the search and close the find bar.
DataTable$clear_find()
DataTable$edit_cell()Edit a cell in a small dialog (needs editable = TRUE).
The default is the cursor cell.
DataTable$edit_cell(position = NULL, column = NULL)
positionPosition in the view (default: the cursor row).
columnColumn name or number (default: the cursor / active column).
DataTable$set_cell()Change one cell of the table's own copy of the data
(the data frame you passed in is never modified; read the result
with $data). Runs on_edit, then sends "datatable.cell_changed"
with row, column, old and value.
DataTable$set_cell(row, column, value)
rowOriginal row number.
columnColumn name or number.
valueNew value (must fit the column type).
DataTable$action_cursor_up()Actions used by the bindings.
DataTable$action_cursor_up()
DataTable$action_cursor_down()Move down.
DataTable$action_cursor_down()
DataTable$action_extend_selection_up()Extend selection upward.
DataTable$action_extend_selection_up()
DataTable$action_extend_selection_down()Extend selection downward.
DataTable$action_extend_selection_down()
DataTable$action_move_column_left()Move the active column left in display order.
DataTable$action_move_column_left()
DataTable$action_move_column_right()Move the active column right in display order.
DataTable$action_move_column_right()
DataTable$action_copy_selection()Copy selected rows.
DataTable$action_copy_selection()
DataTable$action_cursor_left()Move left (cell cursor) or scroll left.
DataTable$action_cursor_left()
DataTable$action_cursor_right()Move right (cell cursor) or scroll right.
DataTable$action_cursor_right()
DataTable$action_page_up()Move one page up.
DataTable$action_page_up()
DataTable$action_page_down()Move one page down.
DataTable$action_page_down()
DataTable$action_first_row()Go to the first row.
DataTable$action_first_row()
DataTable$action_last_row()Go to the last row.
DataTable$action_last_row()
DataTable$action_open_find()Open the find bar (Ctrl+F).
DataTable$action_open_find()
DataTable$action_open_goto()Open the "go to row" bar (Ctrl+G).
DataTable$action_open_goto()
DataTable$action_find_next()Go to the next match (F3).
DataTable$action_find_next()
DataTable$action_find_previous()Go to the previous match (Shift+F3).
DataTable$action_find_previous()
DataTable$action_widen_column()Make the active column one cell wider (Alt+Right).
DataTable$action_widen_column()
DataTable$action_narrow_column()Make the active column one cell narrower (Alt+Left).
DataTable$action_narrow_column()
DataTable$action_sort_column()Sort by the active column (S): ascending, descending, off.
DataTable$action_sort_column()
DataTable$action_activate()Send "datatable.row_activated" for the cursor row
(or edit the cell when the table is editable).
DataTable$action_activate()
DataTable$on_mouse_down()Mouse: clicking a row moves the cursor, clicking the
header sends "datatable.header_selected" (and sorts when
header_sort is on); dragging a column separator in the header
resizes the column; a double click edits a cell of an editable table.
DataTable$on_mouse_down(event)
eventA MouseEvent.
DataTable$on_drag_move()Resizing a column by dragging its header separator.
DataTable$on_drag_move(event)
eventA MouseEvent.
DataTable$on_drag_end()Ends a column resize.
DataTable$on_drag_end(event)
eventA MouseEvent.
DataTable$on_key()Keys for the find / go-to bar while it is open.
DataTable$on_key(event)
eventA KeyEvent.
DataTable$on_paste()Pasted text goes into the find / go-to bar when open.
DataTable$on_paste(event)
eventA PasteEvent.
DataTable$on_mouse_scroll()The mouse wheel scrolls three rows.
DataTable$on_mouse_scroll(event)
eventA MouseEvent.
DataTable$content_width()Natural width: all columns.
DataTable$content_width()
DataTable$content_height()Natural height: header plus rows (at most 1000).
DataTable$content_height(width)
widthContent width.
DataTable$paint()Draw the visible part of the table.
DataTable$paint(buffer, area, st)
bufferA ScreenBuffer.
areaVisible part of the region.
stComputed style.
DataTable$clone()The objects of this class are cloneable with this method.
DataTable$clone(deep = FALSE)
deepWhether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.