blob: 0249e6991e2099aea171ea08f5c2f38aa0dac482 [file] [log] [blame]
Hao Zhu2b739ac2020-08-15 01:38:51 -04001% Generated by roxygen2: do not edit by hand
Hao Zhuf2be4822020-08-18 07:44:10 -04002% Please edit documentation in R/kbl.R
3\name{kbl}
4\alias{kbl}
Hao Zhu2b739ac2020-08-15 01:38:51 -04005\title{Wrapper function of knitr::kable}
6\usage{
Hao Zhuf2be4822020-08-18 07:44:10 -04007kbl(
Hao Zhu2b739ac2020-08-15 01:38:51 -04008 x,
9 format,
10 digits = getOption("digits"),
11 row.names = NA,
12 col.names = NA,
13 align,
14 caption = NULL,
15 label = NULL,
16 format.args = list(),
17 escape = TRUE,
18 table.attr = "",
19 booktabs = FALSE,
20 longtable = FALSE,
21 valign = "t",
22 position = "",
23 centering = TRUE,
24 vline = getOption("knitr.table.vline", if (booktabs) "" else "|"),
25 toprule = getOption("knitr.table.toprule", if (booktabs) "\\\\toprule" else
26 "\\\\hline"),
27 bottomrule = getOption("knitr.table.bottomrule", if (booktabs) "\\\\bottomrule" else
28 "\\\\hline"),
29 midrule = getOption("knitr.table.midrule", if (booktabs) "\\\\midrule" else
30 "\\\\hline"),
31 linesep = if (booktabs) c("", "", "", "", "\\\\addlinespace") else "\\\\hline",
32 caption.short = "",
33 table.envir = if (!is.null(caption)) "table",
34 ...
35)
36}
37\arguments{
38\item{x}{For \code{kable()}, \code{x} is an R object, which is typically a
39matrix or data frame. For \code{kables()}, a list with each element being a
40returned value from \code{kable()}.}
41
42\item{format}{A character string. Possible values are \code{latex},
43\code{html}, \code{pipe} (Pandoc's pipe tables), \code{simple} (Pandoc's
44simple tables), and \code{rst}. The value of this argument will be
45automatically determined if the function is called within a \pkg{knitr}
46document. The \code{format} value can also be set in the global option
47\code{knitr.table.format}. If \code{format} is a function, it must return a
48character string.}
49
50\item{digits}{Maximum number of digits for numeric columns, passed to
51\code{round()}. This can also be a vector of length \code{ncol(x)}, to set
52the number of digits for individual columns.}
53
54\item{row.names}{Logical: whether to include row names. By default, row names
55are included if \code{rownames(x)} is neither \code{NULL} nor identical to
56\code{1:nrow(x)}.}
57
58\item{col.names}{A character vector of column names to be used in the table.}
59
60\item{align}{Column alignment: a character vector consisting of \code{'l'}
61(left), \code{'c'} (center) and/or \code{'r'} (right). By default or if
62\code{align = NULL}, numeric columns are right-aligned, and other columns
63are left-aligned. If \code{length(align) == 1L}, the string will be
64expanded to a vector of individual letters, e.g. \code{'clc'} becomes
65\code{c('c', 'l', 'c')}, unless the output format is LaTeX.}
66
67\item{caption}{The table caption.}
68
69\item{label}{The table reference label. By default, the label is obtained
70from \code{knitr::\link[knitr]{opts_current}$get('label')}.}
71
72\item{format.args}{A list of arguments to be passed to \code{\link{format}()}
73to format table values, e.g. \code{list(big.mark = ',')}.}
74
75\item{escape}{Boolean; whether to escape special characters when producing
76HTML or LaTeX tables. When \code{escape = FALSE}, you have to make sure
77that special characters will not trigger syntax errors in LaTeX or HTML.}
78
79\item{table.attr}{A character string for addition HTML table attributes.
80This is convenient if you simply want to add a few HTML classes or styles.
81For example, you can put 'class="table" style="color: red"'.}
82
83\item{booktabs}{T/F for whether to enable the booktabs format for tables. I
84personally would recommend you turn this on for every latex table except
85some special cases.}
86
87\item{longtable}{T/F for whether to use the longtable format. If you have a
88table that will span over two or more pages, you will have to turn this on.}
89
90\item{valign}{You probably won't need to adjust this latex option very often.
91If you are familar with latex tables, this is the optional position for the
92tabular environment controling the vertical position of the table relative
93to the baseline of the surrounding text. Possible choices are \code{b}, \code{c} and
94\code{t} (default).}
95
96\item{position}{This is the "real" or say floating position for the latex
97table environment. The \code{kable} only puts tables in a table environment when
98a caption is provided. That is also the reason why your tables will be
99floating around if you specify captions for your table. Possible choices are
100\code{h} (here), \code{t} (top, default), \code{b} (bottom) and \code{p} (on a dedicated page).}
101
102\item{centering}{T (default)/F. Whether to center tables in the table
103environment.}
104
105\item{vline}{vertical separator. Default is nothing for booktabs
106tables but "|" for normal tables.}
107
108\item{toprule}{toprule. Default is hline for normal table but toprule for
109booktabs tables.}
110
111\item{bottomrule}{bottomrule. Default is hline for normal table but
112bottomrule for booktabs tables.}
113
114\item{midrule}{midrule. Default is hline for normal table but midrule for
115booktabs tables.}
116
117\item{linesep}{By default, in booktabs tables, \code{kable} insert an extra space
118every five rows for clear display. If you don't want this feature or if you
119want to do it in a different pattern, you can consider change this option.
120The default is c('', '', '', '', '\\addlinespace'). Also, if you are not
121using booktabs, but you want a cleaner display, you can change this to ''.}
122
123\item{caption.short}{Another latex feature. Short captions for tables}
124
125\item{table.envir}{You probably don't need to change this as well. The
126default setting is to put a table environment outside of tabular if a
127caption is provided.}
128
129\item{...}{Other arguments (see Examples).}
130}
131\description{
132knitr's kable function is the foundation of this package.
133However, it has many latex/html specific arguments hidden under the ground
134unless you check its source code. This wrapper function is created to
135provide better documentation (and auto-complete yay) and at the same time,
136solve the auto format setting in a better way.
137}