dynamictable: Dynamic Table

Description Usage Arguments Details Value Column Names Options Recognized Options Author(s) See Also Examples

Description

Light-weight, non-paginated HTML table with basic sorting, filtering and automated markup functionality

Usage

1
2
3
4
5
6
7
8
dynamictable(data, cols = NA, options = list(), params = list(),
  file = NA, header = "", title = NA, footer = "", sortby = "",
  show.rownames = TRUE, facet.title = TRUE, show.attr = TRUE,
  auto.url = TRUE, auto.title = TRUE, auto.factor = TRUE,
  min.level = NA, factor.colors = "hash", style = character(),
  favicon = NA,
  numeric.style = "text-align: right; font-family: monospace;",
  display.url = TRUE)

Arguments

data

The only required argument, an R object to be displayed, typically a data.frame, matrix or array. Vectors will be shown as a table with a single column.

cols

The columns to display. If NA (Default) then all columns in data will be shown (with some exceptions - see auto.url and auto.title). Alternatively a character vector of column names can be provided, to show only a subset of columns, or to change their order.

options

List of configuration options, keyed by the column names of x, sub-keyed by parameter name. See Options below for more details

params

A fallback to options, useful for providing default values. It is keyed first by parameter name, then column. If a parameter is defined in both options and params, the options value will be used

file

File path for output. If not provided, a temporary path will be used

header

HTML to display at top of document. If it begins with '<' it will be presumed to contain HTML markup and will be used as-is, otherwise it will be escaped

title

Text to define the HTML <title> block (displayed on the browser's window frame). If NA will default to header

footer

Text to add at the end of the document, after the table. Like header, will be escaped unless the first character is '<'

sortby

Column for initial sort of displayed data

show.rownames

When TRUE (default) the first column will be rownames, if set

facet.title

If TRUE (default) then any column titles set with the 'coltitle' option will also be shown as descriptive text above the faceting buttons.

show.attr

When TRUE (default) then some object attributes will be shown at the end of the table. Attributes will be listed only if the value is atomic, and if the key is not 'reserved' (names, dims, etc)

auto.url

If TRUE (default), will look for data/URL column pairs, such that a column 'foo URL' (or 'foo link') will be hidden and instead used as a hyperlink for column 'foo', provided that 'foo' exists

auto.title

Like auto.url, but if TRUE (default) will supress display of 'foo title' and use it for mouse-over title text on column 'foo' instead. Also matches 'foo description'

auto.factor

If TRUE (default), then any is.factor() columns will have faceting widgets set for them. These are buttons for each factor level that toggle row visibility on and off

min.level

Default NA, a minimum factor level count. Can be set here for all factors, or applied to individual columns, see the 'factor' section for more information.

factor.colors

Default 'hash', controls auto-generated colors assigned to factor levels. The value can also be set for each column, see the 'factor' section for more information.

style

Character vector of CSS styles to add to document

favicon

If NA (default) a default favicon will be assigned to the document. If NULL, no favicon will be set. Otherwise should be an appropriate URL or an HTML data block.

numeric.style

Default 'text-align: right; font-family: monospace;'. CSS styling of table columns is awkward, it is easiest to have this as an explicit parameter with explicit CSS code, rather than trying to set a particular class.

display.url

If TRUE (default), browseURL() will be called to display the newly-created output

Details

dynamictable was built with the following design goals:

Value

The file path of the generated HTML document

Column Names

Column names have loose matching - an attempt will first be made with an exact, case-sensitive search; If that fails a case-insensitive attempt will be made.

In addition, the special token '*' will match ALL columns

Finally, if row names have been added, that column can be configured with the 'dtRowNames' column name.

Options

The options parameter should be a list, with column names corresponding to the column names of data. You need only include those columns you wish to configure. Each column should itself be a list of specific parameters to set. Most of those parameters will have simple values, but a few can optionally be provided as lists themselves, so for example:

dynamictable(mtcars, options=list(cyl=list(factor=TRUE), hp=list(gradient=list( colors=c("yellow","purple")))))

The call is requesting that "cyl" be treated as a factor, an option that could be configured with a sub-list, but passing TRUE will cause default values to be applied. The use of a sub-list to define the 'gradient' option for column "hp" allows finer-grained configuration.

Recognized Options

Author(s)

Charles A Tilford, cran@agent.fastmail.com

See Also

Library "DT", which implements jQuery DataTables. These are paginated and are likley more appropriate for visualizing larger (10,000+ rows) tables: <URL: http://rstudio.github.io/DT>

Examples

 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
## Quick table generation

dynamictable(mtcars)

## Using the "*" wildcard to apply a setting (here a gradient) to all columns

dynamictable(state.x77, options = list("*"=list(gradient=TRUE)))

## A highly customized view of mtcars to illustrate most options:

demo("hyperCustomizedTable", package="dynamictable", ask=FALSE)

## Stress-test with 1000 rows. The performance is not stellar - tens
## of thoushands of rows are passable in Chrome, but awkward in Firefox.
## For larger datasets a paginated browser (eg DT) is likely more
## appropriate

demo("largeDataSets", package="dynamictable", ask=FALSE)

## Some simple factorized data sets:

dynamictable(texteditorplatforms)
dynamictable(typesystemcomparison)

## Factor-rich table, with min.level set to consolidate uncommon levels:

dynamictable(vampiretraits, min.level=2)

maptracker/dynamictable documentation built on May 21, 2019, 11:27 a.m.