tab_df: Print data frames as HTML table.

Description Usage Arguments Details Value Note Examples

View source: R/html_print.R

Description

These functions print data frames as HTML-table, showing the results in RStudio's viewer pane or in a web browser.

Usage

1
2
3
4
5
6
7
8
9
tab_df(x, title = NULL, footnote = NULL, col.header = NULL,
  show.type = FALSE, show.rownames = TRUE, show.footnote = FALSE,
  alternate.rows = FALSE, sort.column = NULL, encoding = "UTF-8",
  CSS = NULL, file = NULL, use.viewer = TRUE, ...)

tab_dfs(x, titles = NULL, footnotes = NULL, col.header = NULL,
  show.type = FALSE, show.rownames = TRUE, show.footnote = FALSE,
  alternate.rows = FALSE, sort.column = NULL, encoding = "UTF-8",
  CSS = NULL, file = NULL, use.viewer = TRUE, ...)

Arguments

x

For tab_df(), a data frame; and for tab_dfs(), a list of data frames.

title, titles, footnote, footnotes

Character vector with table caption(s) resp. footnote(s). For tab_df(), must be a character of length 1; for tab_dfs(), a character vector of same length as x (i.e. one title or footnote per data frame).

col.header

Character vector with elements used as column header for the table. If NULL, column names from x are used as column header.

show.type

Logical, if TRUE, adds information about the variable type to the variable column.

show.rownames

Logical, if TRUE, adds a column with the data frame's rowname to the table output.

show.footnote

Logical, if TRUE,adds a summary footnote below the table. For tab_df(), specify the string in footnote, for tab_dfs() provide a character vector in footnotes.

alternate.rows

Logical, if TRUE, rows are printed in alternatig colors (white and light grey by default).

sort.column

Numeric vector, indicating the index of the column that should sorted. by default, the column is sorted in ascending order. Use negative index for descending order, for instance, sort.column = -3 would sort the third column in descending order. Note that the first column with rownames is not counted.

encoding

Character vector, indicating the charset encoding used for variable and value labels. Default is "UTF-8". For Windows Systems, encoding = "Windows-1252" might be necessary for proper display of special characters.

CSS

A list with user-defined style-sheet-definitions, according to the official CSS syntax. See 'Details' or this package-vignette.

file

Destination file, if the output should be saved as file. If NULL (default), the output will be saved as temporary file and openend either in the IDE's viewer pane or the default web browser.

use.viewer

Logical, if TRUE, the HTML table is shown in the IDE's viewer pane. If FALSE or no viewer available, the HTML table is opened in a web browser.

...

Currently not used.

Details

How do I use CSS-argument?

With the CSS-argument, the visual appearance of the tables can be modified. To get an overview of all style-sheet-classnames that are used in this function, see return value page.style for details. Arguments for this list have following syntax:

  1. the class-name as argument name and

  2. each style-definition must end with a semicolon

You can add style information to the default styles by using a + (plus-sign) as initial character for the argument attributes. Examples:

See further examples in this package-vignette.

Value

A list with following items:

Note

The HTML tables can either be saved as file and manually opened (use argument file) or they can be saved as temporary files and will be displayed in the RStudio Viewer pane (if working with RStudio) or opened with the default web browser. Displaying resp. opening a temporary file is the default behaviour.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
data(iris)
data(mtcars)
tab_df(iris[1:5, ])
tab_dfs(list(iris[1:5, ], mtcars[1:5, 1:5]))

# sort 2nd column ascending
tab_df(iris[1:5, ], sort.column = 2)

# sort 2nd column descending
tab_df(iris[1:5, ], sort.column = -2)
## End(Not run)

sjPlot documentation built on Aug. 23, 2018, 5:03 p.m.