Hao Zhu | 2b739ac | 2020-08-15 01:38:51 -0400 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
Hao Zhu | f2be482 | 2020-08-18 07:44:10 -0400 | [diff] [blame] | 2 | % Please edit documentation in R/kbl.R |
| 3 | \name{kbl} |
| 4 | \alias{kbl} |
Hao Zhu | 2b739ac | 2020-08-15 01:38:51 -0400 | [diff] [blame] | 5 | \title{Wrapper function of knitr::kable} |
| 6 | \usage{ |
Hao Zhu | f2be482 | 2020-08-18 07:44:10 -0400 | [diff] [blame] | 7 | kbl( |
Hao Zhu | 2b739ac | 2020-08-15 01:38:51 -0400 | [diff] [blame] | 8 | 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 |
| 39 | matrix or data frame. For \code{kables()}, a list with each element being a |
| 40 | returned 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 |
| 44 | simple tables), and \code{rst}. The value of this argument will be |
| 45 | automatically determined if the function is called within a \pkg{knitr} |
| 46 | document. 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 |
| 48 | character 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 |
| 52 | the number of digits for individual columns.} |
| 53 | |
| 54 | \item{row.names}{Logical: whether to include row names. By default, row names |
| 55 | are 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 |
| 63 | are left-aligned. If \code{length(align) == 1L}, the string will be |
| 64 | expanded 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 Murdoch | 7897b5f | 2021-12-09 16:33:16 -0500 | [diff] [blame^] | 70 | from \code{knitr::\link[knitr]{opts_current}$get('label')}. To disable the label, |
| 71 | use \code{label = NA}.} |
Hao Zhu | 2b739ac | 2020-08-15 01:38:51 -0400 | [diff] [blame] | 72 | |
| 73 | \item{format.args}{A list of arguments to be passed to \code{\link{format}()} |
| 74 | to format table values, e.g. \code{list(big.mark = ',')}.} |
| 75 | |
| 76 | \item{escape}{Boolean; whether to escape special characters when producing |
| 77 | HTML or LaTeX tables. When \code{escape = FALSE}, you have to make sure |
| 78 | that special characters will not trigger syntax errors in LaTeX or HTML.} |
| 79 | |
| 80 | \item{table.attr}{A character string for addition HTML table attributes. |
| 81 | This is convenient if you simply want to add a few HTML classes or styles. |
| 82 | For 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 |
| 85 | personally would recommend you turn this on for every latex table except |
| 86 | some special cases.} |
| 87 | |
| 88 | \item{longtable}{T/F for whether to use the longtable format. If you have a |
| 89 | table 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. |
| 92 | If you are familar with latex tables, this is the optional position for the |
| 93 | tabular environment controling the vertical position of the table relative |
| 94 | to 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 |
| 98 | table environment. The \code{kable} only puts tables in a table environment when |
| 99 | a caption is provided. That is also the reason why your tables will be |
| 100 | floating 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 |
| 104 | environment.} |
| 105 | |
| 106 | \item{vline}{vertical separator. Default is nothing for booktabs |
| 107 | tables but "|" for normal tables.} |
| 108 | |
| 109 | \item{toprule}{toprule. Default is hline for normal table but toprule for |
| 110 | booktabs tables.} |
| 111 | |
| 112 | \item{bottomrule}{bottomrule. Default is hline for normal table but |
| 113 | bottomrule for booktabs tables.} |
| 114 | |
| 115 | \item{midrule}{midrule. Default is hline for normal table but midrule for |
| 116 | booktabs tables.} |
| 117 | |
| 118 | \item{linesep}{By default, in booktabs tables, \code{kable} insert an extra space |
| 119 | every five rows for clear display. If you don't want this feature or if you |
| 120 | want to do it in a different pattern, you can consider change this option. |
| 121 | The default is c('', '', '', '', '\\addlinespace'). Also, if you are not |
| 122 | using 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 |
| 127 | default setting is to put a table environment outside of tabular if a |
| 128 | caption is provided.} |
| 129 | |
Duncan Murdoch | 7897b5f | 2021-12-09 16:33:16 -0500 | [diff] [blame^] | 130 | \item{...}{Other arguments (see Examples and References).} |
Hao Zhu | 2b739ac | 2020-08-15 01:38:51 -0400 | [diff] [blame] | 131 | } |
| 132 | \description{ |
| 133 | knitr's kable function is the foundation of this package. |
| 134 | However, it has many latex/html specific arguments hidden under the ground |
| 135 | unless you check its source code. This wrapper function is created to |
| 136 | provide better documentation (and auto-complete yay) and at the same time, |
| 137 | solve the auto format setting in a better way. |
| 138 | } |