blob: 06f1f37e61f2b6f12fcac138ae378ceb686b9ea4 [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
Duncan Murdoch7897b5f2021-12-09 16:33:16 -050070from \code{knitr::\link[knitr]{opts_current}$get('label')}. To disable the label,
71use \code{label = NA}.}
Hao Zhu2b739ac2020-08-15 01:38:51 -040072
73\item{format.args}{A list of arguments to be passed to \code{\link{format}()}
74to format table values, e.g. \code{list(big.mark = ',')}.}
75
76\item{escape}{Boolean; whether to escape special characters when producing
77HTML or LaTeX tables. When \code{escape = FALSE}, you have to make sure
78that special characters will not trigger syntax errors in LaTeX or HTML.}
79
80\item{table.attr}{A character string for addition HTML table attributes.
81This is convenient if you simply want to add a few HTML classes or styles.
82For example, you can put 'class="table" style="color: red"'.}
83
84\item{booktabs}{T/F for whether to enable the booktabs format for tables. I
85personally would recommend you turn this on for every latex table except
86some special cases.}
87
88\item{longtable}{T/F for whether to use the longtable format. If you have a
89table that will span over two or more pages, you will have to turn this on.}
90
91\item{valign}{You probably won't need to adjust this latex option very often.
92If you are familar with latex tables, this is the optional position for the
93tabular environment controling the vertical position of the table relative
94to the baseline of the surrounding text. Possible choices are \code{b}, \code{c} and
95\code{t} (default).}
96
97\item{position}{This is the "real" or say floating position for the latex
98table environment. The \code{kable} only puts tables in a table environment when
99a caption is provided. That is also the reason why your tables will be
100floating around if you specify captions for your table. Possible choices are
101\code{h} (here), \code{t} (top, default), \code{b} (bottom) and \code{p} (on a dedicated page).}
102
103\item{centering}{T (default)/F. Whether to center tables in the table
104environment.}
105
106\item{vline}{vertical separator. Default is nothing for booktabs
107tables but "|" for normal tables.}
108
109\item{toprule}{toprule. Default is hline for normal table but toprule for
110booktabs tables.}
111
112\item{bottomrule}{bottomrule. Default is hline for normal table but
113bottomrule for booktabs tables.}
114
115\item{midrule}{midrule. Default is hline for normal table but midrule for
116booktabs tables.}
117
118\item{linesep}{By default, in booktabs tables, \code{kable} insert an extra space
119every five rows for clear display. If you don't want this feature or if you
120want to do it in a different pattern, you can consider change this option.
121The default is c('', '', '', '', '\\addlinespace'). Also, if you are not
122using booktabs, but you want a cleaner display, you can change this to ''.}
123
124\item{caption.short}{Another latex feature. Short captions for tables}
125
126\item{table.envir}{You probably don't need to change this as well. The
127default setting is to put a table environment outside of tabular if a
128caption is provided.}
129
Duncan Murdoch7897b5f2021-12-09 16:33:16 -0500130\item{...}{Other arguments (see Examples and References).}
Hao Zhu2b739ac2020-08-15 01:38:51 -0400131}
132\description{
133knitr's kable function is the foundation of this package.
134However, it has many latex/html specific arguments hidden under the ground
135unless you check its source code. This wrapper function is created to
136provide better documentation (and auto-complete yay) and at the same time,
137solve the auto format setting in a better way.
138}