table_options(...)
booktabs(...)
htmloptions(head=TRUE, table=TRUE, pad=FALSE, ...)table_options() and booktabs() return the previous settings.htmloptions() returns a list of settings without changing the defaults.
table_options() function sets a number of options that control formatting. Currently the
options that affect both LaTeX and HTML output are:
justification = "c"
rowlabeljustification = "l"
doBegin, doHeader, doBody, doFooter, doEndTRUE) control the inclusion of specific parts of
the output table.These options are only used for LaTeX output:
tabular = "tabular""longtable" might
make sense.
toprule, midrule, bottomrule"\hline".
titlerule = NULLNULL, no underlining
is done.
latexleftpad, latexrightpad, latexminus, mathmodeTRUE (the default), blanks
in R's formatting are converted to hard spaces in the LaTeX output, and negative
signs are rendered properly. Generally this makes output look better, but
the .tex input may be harder to read.
These options are only used for HTML output:
doHTMLheader, doCSS, doHTMLbodyHTMLhead, CSS, HTMLbody"CHARSET" will be replaced with the result of
localeToCharset() in the HTMLhead. The string
"#ID" will be replaced with "#" followed by the id
argument to html.tabular (or removed if that is blank).
HTMLcaptionNULL, no
caption is emitted.
HTMLleftpad, HTMLrightpad, HTMLminusTRUE, blanks
in R's formatting are converted to hard spaces in the HTML output, and negative
signs are rendered properly. Generally this makes output look better, but
cut and paste from the table may include these special characters
and not be recognized by other software. The default is FALSE.
HTMLattributes""
declaration at the top of the table. By
default, the attributes are 'frame="hsides" rules="groups"'.
These set horizontal rules on the top and bottom of the table and between the header,
body, and footer (if present).
HTMLfooterNULL for no footer, or HTML code to insert in the table. Note
that in HTML the footer should be specified before the body of the table;
html.tabular will do this if both are written in the same call.
These may be set persistently by calling table_options(), or just for the duration
of the call by passing them in a list via latex(options=list( ... )). Additional
... arguments to latex are passed to format.
The booktabs() function sets the table_options() values to different defaults,
suitable for use with the booktabs LaTeX package.
The htmloptions() function constructs a list suitable for the options
argument to html.tabular, with grouping of options that
rarely differ from each other.
Note that any LaTeX code can be used in the rule options; for example, see
the longtable example in the vignette. Material to go above the headers
goes into toprule, material between the headers and the body goes into midrule,
and material at the bottom of the table goes into bottomrule.
latex.tabular, html.tabular
tab <- tabular( (Species + 1) ~ (n=1) + Format(digits=2)*
(Sepal.Length + Sepal.Width)*(mean + sd), data=iris )
latex(tab)
save <- booktabs()
latex(tab)
table_options(save)
f <- tempfile(fileext = ".html")
browseURL( html(tab, f,
options=htmloptions(HTMLcaption="Table of Iris Data",
pad = TRUE))$file )
Run the code above in your browser using DataLab