print.xtable {xtable}R Documentation

Print Export Tables


Function returning and displaying or writing to disk the LaTeX or HTML code associated with the supplied object of class xtable.


print.xtable(x, type="latex", file="", append=FALSE, floating=TRUE, table.placement = "ht", caption.placement="bottom", latex.environments=c("center"),tabular.environment = "tabular", size=NULL, hline.after=NULL, NA.string = "", ...)


x An object of class "xtable".
type Type of table to produce. Possible values for type are "latex" or "html". Default value is "latex".
file Name of file where the resulting code should be saved. If file=="", 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 "".
append If TRUE and file!="", code will be appended to file instead of overwriting file. Default value is FALSE.
floating If TRUE and type="latex", the resulting table will be a floating table (using \begin{table} and \end{table}). Default value is TRUE.
table.placement If floating=TRUE and type="latex", the floating table will have placement given by table.placement where table.placement must be NULL or contain only elements of {"h","t","b","p","!","H"}. Default value is "ht".
caption.placement The caption will be have placed at the bottom of the table if caption.placement is "bottom" and at the top of the table if it equals "top". Default value is "bottom".
latex.environments If floating=TRUE and type="latex", the specificed latex environments (provided as a character vector) will enclose the tabuluar environment. Default value is "center".
tabular.environment When type="latex", the tabular environment that will be used. Defaults to "tabular". When working with tables that extend more than one page, using tabular.environment="longtable" and the LaTeX package "longtable" (see Fairbairns, 2005) allows one to typeset them uniformly. Note that "floating" should be set to "FALSE" when using the "longtable" environment.
size An arbitrary character vector intended to be used to set the font size in a LaTeX table. The supplied value (if not NULL) is inserted just before the tabular environment starts. Default value is NULL.
hline.after When type="latex", a vector of numbers between 1 and "nrow(x)", inclusive, indicating the rows after which a horizontal line should appear. If NULL is used, no extra lines are produced. Default value is NULL.
NA.string String to be used for missing values in table enteries. Default value is "".
... Additional arguments. (Currently ignored.)


This function displays or writes to disk the code to produce a table associated with an object x of class "xtable". The resulting code is either a LaTeX or HTML table, depending on the value of type. The function also (invisibly) returns a character vector of the results (which can be helpful for post-processing).


David Dahl with contributions and suggestions from many others (see source code).


Fairbairns, Robin (2005) Tables longer than a single page The UK List of TeX Frequently Asked Questions on the Web.

See Also

xtable, caption, label, vsep, align, digits, display, formatC

[Package xtable version 1.3-0 Index]