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 |
| 70 | from \code{knitr::\link[knitr]{opts_current}$get('label')}.} |
| 71 | |
| 72 | \item{format.args}{A list of arguments to be passed to \code{\link{format}()} |
| 73 | to format table values, e.g. \code{list(big.mark = ',')}.} |
| 74 | |
| 75 | \item{escape}{Boolean; whether to escape special characters when producing |
| 76 | HTML or LaTeX tables. When \code{escape = FALSE}, you have to make sure |
| 77 | that special characters will not trigger syntax errors in LaTeX or HTML.} |
| 78 | |
| 79 | \item{table.attr}{A character string for addition HTML table attributes. |
| 80 | This is convenient if you simply want to add a few HTML classes or styles. |
| 81 | For 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 |
| 84 | personally would recommend you turn this on for every latex table except |
| 85 | some special cases.} |
| 86 | |
| 87 | \item{longtable}{T/F for whether to use the longtable format. If you have a |
| 88 | table 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. |
| 91 | If you are familar with latex tables, this is the optional position for the |
| 92 | tabular environment controling the vertical position of the table relative |
| 93 | to 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 |
| 97 | table environment. The \code{kable} only puts tables in a table environment when |
| 98 | a caption is provided. That is also the reason why your tables will be |
| 99 | floating 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 |
| 103 | environment.} |
| 104 | |
| 105 | \item{vline}{vertical separator. Default is nothing for booktabs |
| 106 | tables but "|" for normal tables.} |
| 107 | |
| 108 | \item{toprule}{toprule. Default is hline for normal table but toprule for |
| 109 | booktabs tables.} |
| 110 | |
| 111 | \item{bottomrule}{bottomrule. Default is hline for normal table but |
| 112 | bottomrule for booktabs tables.} |
| 113 | |
| 114 | \item{midrule}{midrule. Default is hline for normal table but midrule for |
| 115 | booktabs tables.} |
| 116 | |
| 117 | \item{linesep}{By default, in booktabs tables, \code{kable} insert an extra space |
| 118 | every five rows for clear display. If you don't want this feature or if you |
| 119 | want to do it in a different pattern, you can consider change this option. |
| 120 | The default is c('', '', '', '', '\\addlinespace'). Also, if you are not |
| 121 | using 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 |
| 126 | default setting is to put a table environment outside of tabular if a |
| 127 | caption is provided.} |
| 128 | |
| 129 | \item{...}{Other arguments (see Examples).} |
| 130 | } |
| 131 | \description{ |
| 132 | knitr's kable function is the foundation of this package. |
| 133 | However, it has many latex/html specific arguments hidden under the ground |
| 134 | unless you check its source code. This wrapper function is created to |
| 135 | provide better documentation (and auto-complete yay) and at the same time, |
| 136 | solve the auto format setting in a better way. |
| 137 | } |