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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/html_print.R
\name{tab_df}
\alias{tab_df}
\alias{tab_dfs}
\title{Print data frames as HTML table.}
\usage{
tab_df(
x,
title = NULL,
footnote = NULL,
col.header = NULL,
show.type = FALSE,
show.rownames = FALSE,
show.footnote = FALSE,
alternate.rows = FALSE,
sort.column = NULL,
digits = 2,
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 = FALSE,
show.footnote = FALSE,
alternate.rows = FALSE,
sort.column = NULL,
digits = 2,
encoding = "UTF-8",
CSS = NULL,
file = NULL,
use.viewer = TRUE,
rnames = NULL,
...
)
}
\arguments{
\item{x}{For \code{tab_df()}, a data frame; and for \code{tab_dfs()}, a
list of data frames.}
\item{title, titles, footnote, footnotes}{Character vector with table
caption(s) resp. footnote(s). For \code{tab_df()}, must be a character
of length 1; for \code{tab_dfs()}, a character vector of same length as
\code{x} (i.e. one title or footnote per data frame).}
\item{col.header}{Character vector with elements used as column header for
the table. If \code{NULL}, column names from \code{x} are used as
column header.}
\item{show.type}{Logical, if \code{TRUE}, adds information about the
variable type to the variable column.}
\item{show.rownames}{Logical, if \code{TRUE}, adds a column with the
data frame's rowname to the table output.}
\item{show.footnote}{Logical, if \code{TRUE},adds a summary footnote below
the table. For \code{tab_df()}, specify the string in \code{footnote},
for \code{tab_dfs()} provide a character vector in \code{footnotes}.}
\item{alternate.rows}{Logical, if \code{TRUE}, rows are printed in
alternatig colors (white and light grey by default).}
\item{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,
\code{sort.column = -3} would sort the third column in descending order.
Note that the first column with rownames is not counted.}
\item{digits}{Numeric, amount of digits after decimal point when rounding
values.}
\item{encoding}{Character vector, indicating the charset encoding used
for variable and value labels. Default is \code{"UTF-8"}. For Windows
Systems, \code{encoding = "Windows-1252"} might be necessary for proper
display of special characters.}
\item{CSS}{A \code{\link{list}} with user-defined style-sheet-definitions,
according to the \href{https://www.w3.org/Style/CSS/}{official CSS syntax}.
See 'Details' or \href{https://strengejacke.github.io/sjPlot/articles/table_css.html}{this package-vignette}.}
\item{file}{Destination file, if the output should be saved as file.
If \code{NULL} (default), the output will be saved as temporary file and
opened either in the IDE's viewer pane or the default web browser.}
\item{use.viewer}{Logical, if \code{TRUE}, the HTML table is shown in the IDE's
viewer pane. If \code{FALSE} or no viewer available, the HTML table is
opened in a web browser.}
\item{...}{Currently not used.}
\item{rnames}{Character vector, can be used to set row names when \code{show.rownames=TRUE}.}
}
\value{
A list with following items:
\itemize{
\item the web page style sheet (\code{page.style}),
\item the HTML content of the data frame (\code{page.content}),
\item the complete HTML page, including header, style sheet and body (\code{page.complete})
\item the HTML table with inline-css for use with knitr (\code{knitr})
\item the file path, if the HTML page should be saved to disk (\code{file})
}
}
\description{
These functions print data frames as HTML-table, showing
the results in RStudio's viewer pane or in a web browser.
}
\details{
\strong{How do I use \code{CSS}-argument?}
\cr \cr
With the \code{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 \code{page.style} for
details. Arguments for this list have following syntax:
\enumerate{
\item the class-name as argument name and
\item 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:
\itemize{
\item \code{table = 'border:2px solid red;'} for a solid 2-pixel table border in red.
\item \code{summary = 'font-weight:bold;'} for a bold fontweight in the summary row.
\item \code{lasttablerow = 'border-bottom: 1px dotted blue;'} for a blue dotted border of the last table row.
\item \code{colnames = '+color:green'} to add green color formatting to column names.
\item \code{arc = 'color:blue;'} for a blue text color each 2nd row.
\item \code{caption = '+color:red;'} to add red font-color to the default table caption style.
}
See further examples in \href{https://strengejacke.github.io/sjPlot/articles/table_css.html}{this package-vignette}.
}
\note{
The HTML tables can either be saved as file and manually opened
(use argument \code{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{
\dontrun{
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)}
}
|