Description Usage Arguments Value References See Also Examples
This is a wrapper around DT::datatable()
with more convenient
defaults. Also, most common elements of options()
argument are moved
to direct arguments list for this function. This removes the necessity to pass
on a long options list (which is not fully documented in the DT package
documentation). It also exposes them auto-complete drop-downs in RStudio IDE.
1 2 3 4 5 6 | datatable_EZ(data, colnames, filter = "none", caption = NULL,
rownames = FALSE, class = "compact display", dom = "lftip",
font_family = "Arial", font_size = 10, font_size_header = font_size + 2,
pageLength = 10, lengthMenu = c(5, 10, 25, 50, 100, 500),
searchHighlight = TRUE, columnDefs = list(), col_widths = NULL,
ordering = TRUE, order = list(), options = list(), ...)
|
data |
a data object (either a matrix or a data frame) |
colnames |
if missing, the column names of the data; otherwise it can be
an unnamed character vector of names you want to show in the table header
instead of the default data column names; alternatively, you can provide a
named numeric or character vector of the form |
filter |
whether/where to use column filters; |
caption |
the table caption; a character vector or a tag object |
rownames |
|
class |
the CSS class(es) of the table, defaults to |
dom |
By default, the table has these DOM elements: the length-(l) menu, the filtering-(f) input box, the table-(t), the information-(i) summary, and the pagination-(p) control. You can choose to display a subset of these elements. See https://datatables.net/reference/option/dom for details. |
font_family, font_size, font_size_header |
control how the table's fonts are rendered in the browser. The default font family is 'Arial' 12 'pt' data cells and 14 'pt' for headers. |
pageLength |
a number of records to be displayed per page when the table loads |
lengthMenu |
a numeric vector of page length drop-down options |
searchHighlight |
a logical; should search expression be highlighted?
Defaults to |
columnDefs |
list of column definitions; see Examples. |
col_widths |
An numeric vector of column widths, in pixels. Must equal
the number of columns in the data. Ignored if |
ordering |
logical; should the table be sortable? |
order |
list of row sorting options; see examples. |
options |
a |
... |
all other arguments passed to |
DT::datatable
object
See http://rstudio.github.io/DT for the full documentation.
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 | library(DT)
# original DT::datatable
datatable(iris)
# no rownumbers by default
datatable_EZ(iris)
# individual option arguments
datatable_EZ(
iris,
# DOM elements (table only)
dom="t",
# column definitions
columnDefs = list(list(width = '50px', targets = c(1, 3))),
# Row Sorting
order = list(list(0, 'desc'), list(1, 'asc'))
)
# specify column widths in pixels
datatable_EZ(
iris,
col_widths = c(50, 50, 300, 50, 300)
)
# disable sorting and searching by user ("static version")
datatable_EZ(iris, ordering = FALSE, dom = "t")
# Pagination
datatable_EZ(mtcars, pageLength = 3, lengthMenu = c(3,5,10))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.