Create a Cheetah Grid widget
cheetah.RdCreates a high-performance table widget using Cheetah Grid.
Usage
cheetah(
data,
columns = NULL,
column_group = NULL,
width = NULL,
height = NULL,
elementId = NULL,
rownames = TRUE,
search = c("disabled", "exact", "contains"),
sortable = TRUE,
editable = FALSE,
disable_column_resize = FALSE,
column_freeze = NULL,
default_row_height = NULL,
default_col_width = NULL,
header_row_height = NULL,
theme = NULL,
font = NULL,
underlay_background_color = NULL,
allow_range_paste = FALSE,
keyboard_options = NULL
)Arguments
- data
A data frame or matrix to display
- columns
A list of column definitions. Each column can be customized using
column_def().- column_group
A list of column groups. Each group can be customized using
- width
Width of the widget
- height
Height of the widget
- elementId
The element ID for the widget
- rownames
Logical. Whether to show rownames. Defaults to TRUE.
- search
Whether to enable a search field on top of the table. Default to
disabled. Useexactfor exact matching orcontainsto get larger matches.- sortable
Logical. Whether to enable sorting on all columns. Defaults to TRUE.
- editable
Logical. Whether to enable cell editing. Defaults to FALSE.
- disable_column_resize
Logical. Whether to disable column resizing. Defaults to FALSE.
- column_freeze
Integer. The number of columns to freeze from the left.
- default_row_height
Integer. The default row height.
- default_col_width
Integer. The default column width.
- header_row_height
Integer. The header row height.
- theme
The theme to use for the widget. Provide a named list of valid styling options to customize the widget. For possible options, see Extend Theme in Cheetah Grid
- font
A String. The font to use for the widget. This is possible to set a font value according to the standard CSS font properties shorthand declaration. For example,
font = "12px Arial, sans-serif". This means that the font size is 12px, the font family is Arial, and the font weight is normal.- underlay_background_color
The underlay background color of the widget.
- allow_range_paste
Logical. Whether to allow range pasting. Defaults to FALSE. To activate this option set
editable = TRUEor ensure a given column is editable.- keyboard_options
A named list of keyboard options. There are four options:
moveCellOnTab. Set toTRUEto enable cell movement by Tab key.moveCellOnEnter. Set toTRUEto enable cell movement by Enter key.deleteCellValueOnDel. Set toTRUEto enable deletion of cell values with the Delete and BackSpace keys. Note that this will only work ifeditableisTRUEor a given column is editable.selectAllOnCtrlA. Set toTRUEto enable select all cells by 'Ctrl + A key.
Value
An HTML widget object of class 'cheetah' that can be:
Rendered in R Markdown documents
Used in Shiny applications
Displayed in R interactive sessions
The widget renders as an HTML table with all specified customizations.
Examples
# Basic usage
cheetah(iris)
# Customize columns
cheetah(
iris,
columns = list(
Sepal.Length = column_def(name = "Length"),
Sepal.Width = column_def(name = "Width"),
Petal.Length = column_def(name = "Length"),
Petal.Width = column_def(name = "Width")
)
)
# Customize rownames
cheetah(
mtcars,
columns = list(
rownames = column_def(width = 150, style = list(color = "red"))
)
)
# Customize column groups
cheetah(
iris,
columns = list(
Sepal.Length = column_def(name = "Length"),
Sepal.Width = column_def(name = "Width"),
Petal.Length = column_def(name = "Length"),
Petal.Width = column_def(name = "Width")
),
column_group = list(
column_group(name = "Sepal", columns = c("Sepal.Length", "Sepal.Width")),
column_group(name = "Petal", columns = c("Petal.Length", "Petal.Width"))
)
)
# Enable search
cheetah(iris, search = "contains")
# Enable sorting
cheetah(iris, sortable = TRUE)
# Enable cell editing
cheetah(iris, editable = TRUE)
# Disable column resizing
cheetah(iris, disable_column_resize = TRUE)
# Freeze columns
cheetah(iris, column_freeze = 2)
# Set default row height
cheetah(iris, default_row_height = 30)