Title: | Display Tree Structured Data using Datatable Widget (DT) |
---|---|
Description: | Wrapper of datatable widget, allowing display of data.tree objects. All arguments of the data.tree become columns and each node is a row. Adds column with buttons allowing folding and unfolding the levels. |
Authors: | Michal Zielaskowski [aut, cre] |
Maintainer: | Michal Zielaskowski <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.98 |
Built: | 2024-11-01 03:54:11 UTC |
Source: | https://github.com/cran/TT |
character vector to demonstrate ordering option. See example of treetable
col_order
col_order
character vector
Simply wrapper on format... family functions of 'DT' package.
For details see: formatCurrency
The wrappers are not affecting behavior of original format... functions
formatCurrency( table, columns, currency = "$", interval = 3, mark = ",", digits = 2, dec.mark = getOption("OutDec"), before = TRUE ) formatDate(table, columns, method = "toDateString", params = NULL) formatPercentage( table, columns, digits = 0, interval = 3, mark = ",", dec.mark = getOption("OutDec") ) formatRound( table, columns, digits = 2, interval = 3, mark = ",", dec.mark = getOption("OutDec") ) formatSignif( table, columns, digits = 2, interval = 3, mark = ",", dec.mark = getOption("OutDec") ) formatString(table, columns, prefix = "", suffix = "") formatStyle( table, columns, valueColumns = columns, target = c("cell", "row"), fontWeight = NULL, color = NULL, backgroundColor = NULL, background = NULL, ... )
formatCurrency( table, columns, currency = "$", interval = 3, mark = ",", digits = 2, dec.mark = getOption("OutDec"), before = TRUE ) formatDate(table, columns, method = "toDateString", params = NULL) formatPercentage( table, columns, digits = 0, interval = 3, mark = ",", dec.mark = getOption("OutDec") ) formatRound( table, columns, digits = 2, interval = 3, mark = ",", dec.mark = getOption("OutDec") ) formatSignif( table, columns, digits = 2, interval = 3, mark = ",", dec.mark = getOption("OutDec") ) formatString(table, columns, prefix = "", suffix = "") formatStyle( table, columns, valueColumns = columns, target = c("cell", "row"), fontWeight = NULL, color = NULL, backgroundColor = NULL, background = NULL, ... )
table |
a table object created from |
columns |
the indices of the columns to be formatted (can be character,
numeric, logical, or a formula of the form |
currency |
the currency symbol |
interval |
put a marker after how many digits of the numbers |
mark |
the marker after every |
digits |
the number of decimal places to round to |
dec.mark |
a character to indicate the decimal point |
before |
whether to place the currency symbol before or after the values |
method |
the method(s) to convert a date to string in JavaScript; see
|
params |
a list parameters for the specific date conversion method,
e.g., for the |
prefix |
string to put in front of the column values |
suffix |
string to put after the column values |
valueColumns |
indices of the columns from which the cell values are
obtained; this can be different with the |
target |
the target to apply the CSS styles to (the current cell or the full row) |
fontWeight |
the font weight, e.g. |
color |
the font color, e.g. |
backgroundColor |
the background color of table cells |
background |
the background of table cells |
... |
other CSS properties, e.g. |
Return formatted 'HTML' widget of 'DataTables'
'data.tree' object that can be used as an example to see how table widget looks like. Each node of 'data.tree' store attributes (dates) with some numbers.
org
org
'data.tree' object with 7 attributes in each node, value of the leaf attributes is some random number, parents value is cumulative sum of children
The attributes are:
name of the node
six consecutive months of the year (Jan-2021, Feb-2021....
)
Wrapper of 'datatable' widget, allowing display of 'data.tree' objects. All arguments of the 'data.tree' become columns and each node is a row. Adds column with buttons allowing folding and unfolding the levels.
treetable(data, color = "#0177A5", colnames = list(), ...)
treetable(data, color = "#0177A5", colnames = list(), ...)
data |
data.tree object. |
color |
base color (hue) to color the table. Each level will differ with saturation and luminosity. |
colnames |
if |
... |
datatable parameters |
Package consist of treetable function (wrapper of 'datatable') that
convert data.tree object to 'dataframe' and 'JS' callback function called
after creating the table. Treetable function ads hidden columns used by 'JS'
for formatting and folding/unfolding level rows. Hidden columns shall be
completely transparent for user
Package also include 'DT::format...' functions wrappers, which are working
exactly as originals, but are necessary to protect special (helper) columns
used by 'JS' callback function for formatting.
Color formatting is done by 'kolorWheel' 'JS' script done by Zalka Erno
e-mail: ern0[at]linkbroker.hu
http://linkbroker.hu/stuff/kolorwheel.js/
Return 'HTML' widget using the 'JavaScript' library 'DataTables'
https://github.com/zielaskowski/tree-table
data("org") data("col_order") colnames <- factor(c("org",org$attributesAll), levels = col_order) treetable(org, color="#FFFFFF", colnames=colnames) # still datatable works as expected when data.frame provided treetable(data.frame( date = seq(as.Date("2015-01-01"), by = "day", length.out = 5), x = 1:5))
data("org") data("col_order") colnames <- factor(c("org",org$attributesAll), levels = col_order) treetable(org, color="#FFFFFF", colnames=colnames) # still datatable works as expected when data.frame provided treetable(data.frame( date = seq(as.Date("2015-01-01"), by = "day", length.out = 5), x = 1:5))