EVOLUTION-MANAGER
Edit File: kable.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Create tables in LaTeX, HTML, Markdown and reStructuredText</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for kable {knitr}"><tr><td>kable {knitr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create tables in LaTeX, HTML, Markdown and reStructuredText</h2> <h3>Description</h3> <p>A very simple table generator, and it is simple by design. It is not intended to replace any other R packages for making tables. The <code>kable()</code> function returns a single table for a single data object, and returns a table that contains multiple tables if the input object is a list of data objects. The <code>kables()</code> function is similar to <code>kable(x)</code> when <code>x</code> is a list of data objects, but <code>kables()</code> accepts a list of <code>kable()</code> values directly instead of data objects (see examples below). </p> <h3>Usage</h3> <pre> kable( x, format, digits = getOption("digits"), row.names = NA, col.names = NA, align, caption = NULL, label = NULL, format.args = list(), escape = TRUE, ... ) kables(x, format, caption = NULL, label = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>For <code>kable()</code>, <code>x</code> is an R object, which is typically a matrix or data frame. For <code>kables()</code>, a list with each element being a returned value from <code>kable()</code>.</p> </td></tr> <tr valign="top"><td><code>format</code></td> <td> <p>A character string. Possible values are <code>latex</code>, <code>html</code>, <code>pipe</code> (Pandoc's pipe tables), <code>simple</code> (Pandoc's simple tables), and <code>rst</code>. The value of this argument will be automatically determined if the function is called within a <span class="pkg">knitr</span> document. The <code>format</code> value can also be set in the global option <code>knitr.table.format</code>. If <code>format</code> is a function, it must return a character string.</p> </td></tr> <tr valign="top"><td><code>digits</code></td> <td> <p>Maximum number of digits for numeric columns, passed to <code>round()</code>. This can also be a vector of length <code>ncol(x)</code>, to set the number of digits for individual columns.</p> </td></tr> <tr valign="top"><td><code>row.names</code></td> <td> <p>Logical: whether to include row names. By default, row names are included if <code>rownames(x)</code> is neither <code>NULL</code> nor identical to <code>1:nrow(x)</code>.</p> </td></tr> <tr valign="top"><td><code>col.names</code></td> <td> <p>A character vector of column names to be used in the table.</p> </td></tr> <tr valign="top"><td><code>align</code></td> <td> <p>Column alignment: a character vector consisting of <code>'l'</code> (left), <code>'c'</code> (center) and/or <code>'r'</code> (right). By default or if <code>align = NULL</code>, numeric columns are right-aligned, and other columns are left-aligned. If <code>length(align) == 1L</code>, the string will be expanded to a vector of individual letters, e.g. <code>'clc'</code> becomes <code>c('c', 'l', 'c')</code>, unless the output format is LaTeX.</p> </td></tr> <tr valign="top"><td><code>caption</code></td> <td> <p>The table caption.</p> </td></tr> <tr valign="top"><td><code>label</code></td> <td> <p>The table reference label. By default, the label is obtained from <code>knitr::<a href="opts_chunk.html">opts_current</a>$get('label')</code>.</p> </td></tr> <tr valign="top"><td><code>format.args</code></td> <td> <p>A list of arguments to be passed to <code><a href="../../base/html/format.html">format</a>()</code> to format table values, e.g. <code>list(big.mark = ',')</code>.</p> </td></tr> <tr valign="top"><td><code>escape</code></td> <td> <p>Boolean; whether to escape special characters when producing HTML or LaTeX tables. When <code>escape = FALSE</code>, you have to make sure that special characters will not trigger syntax errors in LaTeX or HTML.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Other arguments (see Examples).</p> </td></tr> </table> <h3>Details</h3> <p>Missing values (<code>NA</code>) in the table are displayed as <code>NA</code> by default. If you want to display them with other characters, you can set the option <code>knitr.kable.NA</code>, e.g. <code>options(knitr.kable.NA = '')</code> to hide <code>NA</code> values. </p> <h3>Value</h3> <p>A character vector of the table source code. </p> <h3>Note</h3> <p>When using <code>kable()</code> as a <em>top-level</em> expression, you do not need to explicitly <code>print()</code> it due to R's automatic implicit printing. When it is wrapped inside other expressions (such as a <code><a href="../../base/html/Control.html">for</a></code> loop), you must explicitly <code>print(kable(...))</code>. </p> <h3>References</h3> <p>See <a href="https://github.com/yihui/knitr-examples/blob/master/091-knitr-table.Rnw">https://github.com/yihui/knitr-examples/blob/master/091-knitr-table.Rnw</a> for some examples in LaTeX, but they also apply to other document formats. </p> <h3>See Also</h3> <p>Other R packages such as <span class="pkg">huxtable</span>, <span class="pkg">xtable</span>, <span class="pkg">kableExtra</span>, and <span class="pkg">tables</span> for HTML and LaTeX tables, and <span class="pkg">ascii</span> and <span class="pkg">pander</span> for different flavors of markdown output and some advanced features and table styles. </p> <h3>Examples</h3> <pre> d1 = head(iris) d2 = head(mtcars) # pipe tables by default kable(d1) kable(d2[, 1:5]) # no inner padding kable(d2, format = "pipe", padding = 0) # more padding kable(d2, format = "pipe", padding = 2) kable(d1, format = "latex") kable(d1, format = "html") kable(d1, format = "latex", caption = "Title of the table") kable(d1, format = "html", caption = "Title of the table") # use the booktabs package kable(mtcars, format = "latex", booktabs = TRUE) # use the longtable package kable(matrix(1000, ncol = 5), format = "latex", digits = 2, longtable = TRUE) # change LaTeX default table environment kable(d1, format = "latex", caption = "My table", table.envir = "table*") # add some table attributes kable(d1, format = "html", table.attr = "id=\"mytable\"") # reST output kable(d2, format = "rst") # no row names kable(d2, format = "rst", row.names = FALSE) # Pandoc simple tables kable(d2, format = "simple", caption = "Title of the table") # format numbers using , as decimal point, and ' as thousands separator x = as.data.frame(matrix(rnorm(60, 1e+06, 10000), 10)) kable(x, format.args = list(decimal.mark = ",", big.mark = "'")) # save the value x = kable(d2, format = "html") cat(x, sep = "\n") # can also set options(knitr.table.format = 'html') so that the output is HTML # multiple tables via either kable(list(x1, x2)) or kables(list(kable(x1), # kable(x2))) kable(list(d1, d2), caption = "A tale of two tables") kables(list(kable(d1, align = "l"), kable(d2)), caption = "A tale of two tables") </pre> <hr /><div style="text-align: center;">[Package <em>knitr</em> version 1.29 <a href="00Index.html">Index</a>]</div> </body></html>