Description Usage Arguments Details Value Author(s) See Also Examples
The function produces objects which can be printed to LaTeX and HTML code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## S3 method for class 'summary'
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, ...)
## S3 method for class 'xtable.summary'
print(x, rules = NULL, header = NULL,
caption.placement = getOption("xtable.caption.placement", "top"),
hline.after = getOption("xtable.hline.after", NULL),
include.rownames = FALSE,
add.to.row = getOption("xtable.add.to.row", NULL),
booktabs = getOption("xtable.booktabs", TRUE),
sanitize.text.function = get_option(x, "sanitize"),
math.style.negative = getOption("xtable.math.style.negative", TRUE),
math.style.exponents = getOption("xtable.math.style.exponents", TRUE),
tabular.environment = getOption("xtable.tabular.environment", "tabular"),
floating = getOption("xtable.floating", FALSE),
latex.environments = getOption("xtable.latex.environments", c("center")),
...)
|
x |
object of class |
caption |
character vector specifying the table's caption; see
|
label |
character string specifying the LaTeX label or HTML anchor; see
|
align |
character string specifying the alignment of table columns; see
|
digits |
numeric vector specifying the number of digits to display in each
column; see |
display |
character string specifying the column types; see
|
rules |
character string specifying the rules to be used. Per default the
|
header |
character string specifying the table header to be used. Per default the
|
caption.placement |
can be either |
hline.after |
vector indicating the rows after which a horizontal line is printed.
Here, the default is to not draw hlines (i.e. |
add.to.row |
list of row numbers ( |
include.rownames |
logical. Always set to |
booktabs |
logical. If |
sanitize.text.function |
All non-numeric enteries (except row and column names) are sanitised
in an attempt to remove characters which have special meaning for
the output format. Per default the function |
math.style.negative |
logical. If |
math.style.exponents |
logical. If |
tabular.environment |
character string. Per default |
floating |
logical. Determine if the table is printed in a floating
environment. Note that the standard default of
|
latex.environments |
character string. Per default |
... |
additional arguments passed to |
We use the standard xtable
function but add a special class
that allows different defaults in the print.xtable
function.
In general, all options of print.xtable
can be used as well as
global options set via options()
. E.g.
options(xtable.booktabs = FALSE
will set the argument booktabs
per default to
FALSE
for all calls to print.xtable
.
After printing, a table with LaTeX markup is returned.
Benjamin Hofner
For details see xtable
and
print.xtable
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | if (require("nlme")) {
## Use dataset Orthodont
data(Orthodont, package = "nlme")
## Get summary for continuous variables
(tab1 <- summarize(Orthodont, type = "numeric"))
## Get summary for categorical variables
(tab2 <- summarize(Orthodont, type = "fac"))
## Using the tables with LaTeX
if (require("xtable")) {
xtable(tab1)
## grouped table
xtable(summarize(Orthodont, group = "Sex"))
xtable(tab2)
}
}
|
Loading required package: car
Loading required package: xtable
Attaching package: 'papeR'
The following object is masked from 'package:utils':
toLatex
Loading required package: nlme
Factors are dropped from the summary
Non-factors are dropped from the summary
Factors are dropped from the summary
%% Output requires \usepackage{booktabs}.
\begin{center}
% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Thu Aug 2 10:45:30 2018
\begin{tabular}{llrrr}
\toprule
& Level & & N & \% \\
\cmidrule{2-2} \cmidrule{4-5}
Subject & M16 & & 4 & 3.7 \\
& M05 & & 4 & 3.7 \\
& M02 & & 4 & 3.7 \\
& M11 & & 4 & 3.7 \\
& M07 & & 4 & 3.7 \\
& M08 & & 4 & 3.7 \\
& M03 & & 4 & 3.7 \\
& M12 & & 4 & 3.7 \\
& M13 & & 4 & 3.7 \\
& M14 & & 4 & 3.7 \\
& M09 & & 4 & 3.7 \\
& M15 & & 4 & 3.7 \\
& M06 & & 4 & 3.7 \\
& M04 & & 4 & 3.7 \\
& M01 & & 4 & 3.7 \\
& M10 & & 4 & 3.7 \\
& F10 & & 4 & 3.7 \\
& F09 & & 4 & 3.7 \\
& F06 & & 4 & 3.7 \\
& F01 & & 4 & 3.7 \\
& F05 & & 4 & 3.7 \\
& F07 & & 4 & 3.7 \\
& F02 & & 4 & 3.7 \\
& F08 & & 4 & 3.7 \\
& F03 & & 4 & 3.7 \\
& F04 & & 4 & 3.7 \\
& F11 & & 4 & 3.7 \\
\cmidrule{2-2} \cmidrule{4-5}
Sex & Male & & 64 & 59.3 \\
& Female & & 44 & 40.7 \\
\bottomrule
\end{tabular}
\end{center}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.