EVOLUTION-MANAGER
Edit File: print.xtable.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: Print Export Tables</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 print.xtable {xtable}"><tr><td>print.xtable {xtable}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Print Export Tables</h2> <h3>Description</h3> <p>Function returning and displaying or writing to disk the LaTeX or HTML code associated with the supplied object of class <code>xtable</code>. </p> <h3>Usage</h3> <pre> ## S3 method for class 'xtable' print(x, type = getOption("xtable.type", "latex"), file = getOption("xtable.file", ""), append = getOption("xtable.append", FALSE), floating = getOption("xtable.floating", TRUE), floating.environment = getOption("xtable.floating.environment", "table"), table.placement = getOption("xtable.table.placement", "ht"), caption.placement = getOption("xtable.caption.placement", "bottom"), caption.width = getOption("xtable.caption.width", NULL), latex.environments = getOption("xtable.latex.environments", c("center")), tabular.environment = getOption("xtable.tabular.environment", "tabular"), size = getOption("xtable.size", NULL), hline.after = getOption("xtable.hline.after", c(-1,0,nrow(x))), NA.string = getOption("xtable.NA.string", ""), include.rownames = getOption("xtable.include.rownames", TRUE), include.colnames = getOption("xtable.include.colnames", TRUE), only.contents = getOption("xtable.only.contents", FALSE), add.to.row = getOption("xtable.add.to.row", NULL), sanitize.text.function = getOption("xtable.sanitize.text.function", NULL), sanitize.rownames.function = getOption("xtable.sanitize.rownames.function", sanitize.text.function), sanitize.colnames.function = getOption("xtable.sanitize.colnames.function", sanitize.text.function), math.style.negative = getOption("xtable.math.style.negative", FALSE), math.style.exponents = getOption("xtable.math.style.exponents", FALSE), html.table.attributes = getOption("xtable.html.table.attributes", "border=1"), print.results = getOption("xtable.print.results", TRUE), format.args = getOption("xtable.format.args", NULL), rotate.rownames = getOption("xtable.rotate.rownames", FALSE), rotate.colnames = getOption("xtable.rotate.colnames", FALSE), booktabs = getOption("xtable.booktabs", FALSE), scalebox = getOption("xtable.scalebox", NULL), width = getOption("xtable.width", NULL), comment = getOption("xtable.comment", TRUE), timestamp = getOption("xtable.timestamp", date()), ...)</pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>An object of class <code>"xtable"</code>.</p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p>Type of table to produce. Possible values for <code>type</code> are <code>"latex"</code> or <code>"html"</code>. Default value is <code>"latex"</code>.</p> </td></tr> <tr valign="top"><td><code>file</code></td> <td> <p>Name of file where the resulting code should be saved. If <code>file=""</code>, output is displayed on screen. Note that the function also (invisibly) returns a character vector of the results (which can be helpful for post-processing). Default value is <code>""</code>.</p> </td></tr> <tr valign="top"><td><code>append</code></td> <td> <p>If <code>TRUE</code> and <code>file!=""</code>, code will be appended to <code>file</code> instead of overwriting <code>file</code>. Default value is <code>FALSE</code>.</p> </td></tr> <tr valign="top"><td><code>floating</code></td> <td> <p>If <code>TRUE</code> and <code>type="latex"</code>, the resulting table will be a floating table (using, for example, <code>\begin{table}</code> and <code>\end{table}</code>). See <code>floating.environment</code> below. Default value is <code>TRUE</code>. </p> </td></tr> <tr valign="top"><td><code>floating.environment</code></td> <td> <p>If <code>floating=TRUE</code> and <code>type="latex"</code>, the resulting table uses the specified floating environment. Possible values include <code>"table"</code>, <code>"table*"</code>, and other floating environments defined in LaTeX packages. Default value is <code>"table"</code>.</p> </td></tr> <tr valign="top"><td><code>table.placement</code></td> <td> <p>If <code>floating=TRUE</code> and <code>type="latex"</code>, the floating table will have placement given by <code>table.placement</code> where <code>table.placement</code> must be <code>NULL</code> or contain only elements of {"h","t","b","p","!","H"}. Default value is <code>"ht"</code>.</p> </td></tr> <tr valign="top"><td><code>caption.placement</code></td> <td> <p>The caption will be placed at the bottom of the table if <code>caption.placement</code> is <code>"bottom"</code> and at the top of the table if it equals <code>"top"</code>. Default value is <code>"bottom"</code>.</p> </td></tr> <tr valign="top"><td><code>caption.width</code></td> <td> <p>The caption will be placed in a <code>"parbox"</code> of the specified width if <code>caption.width</code> is not <code>NULL</code> and <code>type="latex"</code>. Default value is <code>NULL</code>.</p> </td></tr> <tr valign="top"><td><code>latex.environments</code></td> <td> <p>If <code>floating=TRUE</code> and <code>type="latex"</code>, the specified LaTeX environments (provided as a character vector) will enclose the tabular environment. Default value is <code>"center"</code>. </p> </td></tr> <tr valign="top"><td><code>tabular.environment</code></td> <td> <p>When <code>type="latex"</code>, the tabular environment that will be used. When working with tables that extend more than one page, using <code>tabular.environment="longtable"</code> with the corresponding LaTeX package (see Fairbairns, 2005) allows one to typeset them uniformly. Note that <code>floating</code> should be set to <code>FALSE</code> when using the <code>longtable</code> environment. Default value is <code>"tabular"</code>.</p> </td></tr> <tr valign="top"><td><code>size</code></td> <td> <p>A character vector that is inserted just before the tabular environment starts. This can be used to set the font size and a variety of other table settings. Initial backslashes are automatically prefixed, if not supplied by user. Default value is <code>NULL</code>. </p> </td></tr> <tr valign="top"><td><code>hline.after</code></td> <td> <p>When <code>type="latex"</code>, a vector of numbers between -1 and <code>nrow(x)</code>, inclusive, indicating the rows after which a horizontal line should appear. If <code>NULL</code> is used no lines are produced. Repeated values are allowed. Default value is <code>c(-1,0,nrow(x))</code> which means draw a line before and after the columns names and at the end of the table.</p> </td></tr> <tr valign="top"><td><code>NA.string</code></td> <td> <p>String to be used for missing values in table entries. Default value is <code>""</code>.</p> </td></tr> <tr valign="top"><td><code>include.rownames</code></td> <td> <p>If <code>TRUE</code> the rows names are printed. Default value is <code>TRUE</code>.</p> </td></tr> <tr valign="top"><td><code>include.colnames</code></td> <td> <p>If <code>TRUE</code> the columns names are printed. Default value is <code>TRUE</code>.</p> </td></tr> <tr valign="top"><td><code>only.contents</code></td> <td> <p>If <code>TRUE</code> only the rows of the table are printed. Default value is <code>FALSE</code>. </p> </td></tr> <tr valign="top"><td><code>add.to.row</code></td> <td> <p>A list of two components. The first component (which should be called 'pos') is a list that contains the position of rows on which extra commands should be added at the end. The second component (which should be called 'command') is a character vector of the same length as the first component, which contains the command that should be added at the end of the specified rows. Default value is <code>NULL</code>, i.e. do not add commands.</p> </td></tr> <tr valign="top"><td><code>sanitize.text.function</code></td> <td> <p>All non-numeric entries (except row and column names) are sanitized in an attempt to remove characters which have special meaning for the output format. If <code>sanitize.text.function</code> is not <code>NULL</code>, it should be a function taking a character vector and returning one, and will be used for the sanitization instead of the default internal function. Default value is <code>NULL</code>.</p> </td></tr> <tr valign="top"><td><code>sanitize.rownames.function</code></td> <td> <p>Like the <code>sanitize.text.function</code>, but applicable to row names. The default uses the <code>sanitize.text.function</code>. </p> </td></tr> <tr valign="top"><td><code>sanitize.colnames.function</code></td> <td> <p>Like the <code>sanitize.text.function</code>, but applicable to column names. The default uses the <code>sanitize.text.function</code>. </p> </td></tr> <tr valign="top"><td><code>math.style.negative</code></td> <td> <p>In a LaTeX table, if <code>TRUE</code>, then use $-$ for the negative sign (as was the behavior prior to version 1.5-3). Default value is <code>FALSE</code>.</p> </td></tr> <tr valign="top"><td><code>math.style.exponents</code></td> <td> <p>In a LaTeX table, if <code>TRUE</code> or <code>"$$"</code>, then use <code style="white-space: pre;">$5 \times 10^{5}$</code> for 5e5. If <code>"ensuremath"</code>, then use <code style="white-space: pre;">\ensuremath{5 \times 10^{5}}</code> for 5e5. If <code>"UTF-8"</code> or <code>"UTF-8"</code>, then use UTF-8 to approximate the LaTeX typsetting for 5e5. Default value is <code>FALSE</code>.</p> </td></tr> <tr valign="top"><td><code>html.table.attributes</code></td> <td> <p>In an HTML table, attributes associated with the <code><TABLE></code> tag. Default value is <code>"border=1"</code>.</p> </td></tr> <tr valign="top"><td><code>print.results</code></td> <td> <p>If <code>TRUE</code>, the generated table is printed to standard output. Set this to <code>FALSE</code> if you will just be using the character vector that is returned invisibly. Default value is <code>TRUE</code>.</p> </td></tr> <tr valign="top"><td><code>format.args</code></td> <td> <p>List of arguments for the <code>formatC</code> function. For example, standard German number separators can be specified as <code>format.args=list(big.mark = "'", decimal.mark = ","))</code>. The arguments <code>digits</code> and <code>format</code> should not be included in this list. See details. Default value is <code>NULL</code>.</p> </td></tr> <tr valign="top"><td><code>rotate.rownames</code></td> <td> <p>If <code>TRUE</code>, the row names are displayed vertically in LaTeX. Default value is <code>FALSE</code>.</p> </td></tr> <tr valign="top"><td><code>rotate.colnames</code></td> <td> <p>If <code>TRUE</code>, the column names are displayed vertically in LaTeX. Default value is <code>FALSE</code>.</p> </td></tr> <tr valign="top"><td><code>booktabs</code></td> <td> <p>If <code>TRUE</code>, the <code>toprule</code>, <code>midrule</code> and <code>bottomrule</code> commands from the LaTeX "booktabs" package are used rather than <code>hline</code> for the horizontal line tags. </p> </td></tr> <tr valign="top"><td><code>scalebox</code></td> <td> <p>If not <code>NULL</code>, a <code>scalebox</code> clause will be added around the tabular environment with the specified value used as the scaling factor. Default value is <code>NULL</code>.</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>If not <code>NULL</code>, the specified value is included in parentheses between the tabular environment <code>begin</code> tag and the alignment specification. This allows specification of the table width when using tabular environments such as <code>tabular*</code> and <code>tabularx</code>. Note that table width specification is not supported with the <code>tabular</code> or <code>longtable</code> environments. Default value is <code>NULL</code>.</p> </td></tr> <tr valign="top"><td><code>comment</code></td> <td> <p>If <code>TRUE</code>, the version and timestamp comment is included. Default value is <code>TRUE</code>. </p> </td></tr> <tr valign="top"><td><code>timestamp</code></td> <td> <p>Timestamp to include in LaTeX comment. Set this to <code>NULL</code> to exclude the timestamp. Default value is <code>date()</code>. </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments. (Currently ignored.) </p> </td></tr> </table> <h3>Details</h3> <p>This function displays or writes to disk the code to produce a table associated with an object <code>x</code> of class <code>"xtable"</code>. The resulting code is either a LaTeX or HTML table, depending on the value of <code>type</code>. The function also (invisibly) returns a character vector of the results (which can be helpful for post-processing). </p> <p>Since version 1.4 the non default behavior of <code>hline.after</code> is changed. To obtain the same results as the previous versions add to the <code>hline.after</code> vector the vector <code>c(-1, 0, nrow(x))</code> where <code>nrow(x)</code> is the numbers of rows of the object. </p> <p>From version 1.4-3, all non-numeric columns are sanitized, and all LaTeX special characters are sanitized for LaTeX output. See Section 3 of the <code>xtableGallery</code> vignette for an example of customizing the sanitization. From version 1.4-4, the sanitization also applies to column names. To remove any text sanitization, specify <code>sanitize.text.function=function(x){x}</code>. </p> <p>From version 1.6-1 the default values for the arguments other than <code>x</code> are obtained using <code>getOption()</code>. Hence the user can set the values once with <code>options()</code> rather than setting them in every call to <code>print.xtable()</code>. </p> <p>The argument <code>format.args</code> is used to supply arguments to the <code>formatC</code> function, but will throw an error if values for <code>digits</code> or <code>format</code> are included in the list of arguments. The recommended approach to specify <code>digits</code> is to supply the argument <code>digits</code> to <code>xtable</code>, and to specify <code>format</code> supply the argument <code>display</code> to <code>xtable</code>. See the examples. </p> <h3>Author(s)</h3> <p>David Dahl <a href="mailto:dahl@stat.byu.edu">dahl@stat.byu.edu</a> with contributions and suggestions from many others (see source code). </p> <h3>References</h3> <p>Fairbairns, Robin (2005) <em>Tables longer than a single page.</em> The UK List of TeX Frequently Asked Questions on the Web. <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=longtab">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=longtab</a> </p> <h3>See Also</h3> <p><code><a href="xtable.html">xtable</a></code>, <code><a href="table.attributes.html">caption</a></code>, <code><a href="table.attributes.html">label</a></code>, <code><a href="table.attributes.html">align</a></code>, <code><a href="table.attributes.html">digits</a></code>, <code><a href="table.attributes.html">display</a></code>, <code><a href="../../base/html/formatc.html">formatC</a></code> </p> <h3>Examples</h3> <pre> df <- data.frame(A = c(1.00123, 33.1, 6), B = c(111111, 3333333, 3123.233)) ## The following code gives the error ## formal argument "digits" matched by multiple actual arguments ## print(xtable(df, display = c("s","e","e")), ## format.args = list(digits = 3, big.mark = " ", decimal.mark = ",")) ## specify digits as argument to xtable instead print(xtable(df, display = c("s","f","f"), digits = 4), format.args = list(big.mark = " ", decimal.mark = ",")) ## The following code gives the error ## formal argument "format" matched by multiple actual arguments ## print(xtable(df, digits = 4), ## format.args = list(format = c("s","e","e"), ## big.mark = " ", decimal.mark = ",")) ## specify format using display argument in xtable print(xtable(df, display = c("s","e","e"), digits = 4), format.args = list(big.mark = " ", decimal.mark = ",")) </pre> <hr /><div style="text-align: center;">[Package <em>xtable</em> version 1.8-4 <a href="00Index.html">Index</a>]</div> </body></html>