Description Usage Arguments Details Value Author(s) See Also Examples
xtableList
creates an object from a list of tables, which can
be used by print.xtableList
to produce a composite table
containing the information from the individual tables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | xtableList(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, ...)
## S3 method for class 'xtableList'
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 = NULL,
NA.string = getOption("xtable.NA.string", ""),
include.rownames = getOption("xtable.include.rownames", TRUE),
colnames.format = "single",
only.contents = getOption("xtable.only.contents", FALSE),
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),
sanitize.subheadings.function =
getOption("xtable.sanitize.subheadings.function",
sanitize.text.function),
sanitize.message.function =
getOption("xtable.sanitize.message.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()),
...)
|
x |
For |
caption |
Character vector of length 1 or 2 containing the
table's caption or title. If length is 2, the second item is the
"short caption" used when LaTeX generates a "List of Tables". Set to
|
label |
Character vector of length 1 containing the LaTeX label
or HTML anchor. Set to |
align |
Character vector of length equal to the number of columns
of the resulting table, indicating the alignment of the corresponding
columns. Also, |
digits |
Either |
display |
Either |
type |
Type of table to produce. Possible values for |
file |
Name of file where the resulting code should be saved. If
|
append |
If |
floating |
If |
floating.environment |
If |
table.placement |
If |
caption.placement |
The caption will be placed at the bottom
of the table if |
caption.width |
The caption will be placed in a |
latex.environments |
If |
tabular.environment |
When |
size |
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 |
hline.after |
When |
NA.string |
String to be used for missing values in table
entries.
Default value is |
include.rownames |
If |
colnames.format |
Either |
only.contents |
If |
add.to.row |
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 |
sanitize.text.function |
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
|
sanitize.rownames.function |
Like the
|
sanitize.colnames.function |
Like the
|
sanitize.subheadings.function |
Like the
|
sanitize.message.function |
Like the
|
math.style.negative |
In a LaTeX table, if |
math.style.exponents |
In a LaTeX table, if |
html.table.attributes |
In an HTML table, attributes associated
with the |
print.results |
If |
format.args |
List of arguments for the |
rotate.rownames |
If |
rotate.colnames |
If |
booktabs |
If |
scalebox |
If not |
width |
If not |
comment |
If |
timestamp |
Timestamp to include in LaTeX comment. Set this
to |
... |
Additional arguments. (Currently ignored.) |
xtableList
produces an object suitable for printing using
print.xtableList
.
The elements of the list x
supplied to xtableList
must
all have the same structure. When these list items are submitted to
xtable
the resulting table must have the same number of columns
with the same column names and type of data.
The values supplied to arguments digits
and display
,
must be composed of elements as specified in those same arguments for
the function xtable
. See the help for
xtable
for details.
print.xtableList
produces tables in two different formats
depending on the value of col.names.format
. If
col.names.format = "single"
, the resulting table has only a
single heading row. If col.names.format = "multiple"
there is a
heading row for each of the subtables making up the complete table.
By default if col.names.format = "single"
, there are horizontal
lines above and below the heading row, and at the end of each
subtable. If col.names.format = "multiple"
, there are
horizontal lines above and below each appearance of the heading row,
and at the end of each subtable.
If "subheadings"
is not NULL
, the individual elements of
this vector (which can include newlines \n
) produce a heading
line or lines for the subtables. When col.names.format =
"multiple"
these subheadings appear above the heading rows.
If "message"
is not NULL
the vector produces a line or
lines at the end of the table.
Consult the vignette ‘The xtableList
Gallery’ to see
the behaviour of these functions.
Note that at present there is no code for type = "html"
.
xtableList
produces an object of class
"xtableList"
. An object of this class is a list of
"xtable"
objects with some additional attributes. Each element
of the list can have a "subheading"
attribute. The list can
also have a "message"
attribute.
print.xtableList
produces a character string containing LaTeX
markup which produces a composite table in a LaTeX document.
David Scott d.scott@auckland.ac.nz.
caption
, label
, align
,
digits
, display
1 2 3 4 5 6 7 8 9 10 | data(mtcars)
mtcars <- mtcars[, 1:6]
mtcarsList <- split(mtcars, f = mtcars$cyl)
attr(mtcarsList, "subheadings") <- paste0("Number of cylinders = ",
names(mtcarsList))
attr(mtcarsList, "message") <- c("Line 1 of Message",
"Line 2 of Message")
xList <- xtableList(mtcarsList)
print.xtableList(xList)
print.xtableList(xList, colnames.format = "multiple")
|
% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Sat Jul 21 22:43:18 2018
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrr}
\hline
& mpg & cyl & disp & hp & drat & wt \\
\hline
\multicolumn{6}{l}{Number of cylinders = 4}\\
Datsun 710 & 22.80 & 4.00 & 108.00 & 93.00 & 3.85 & 2.32 \\
Merc 240D & 24.40 & 4.00 & 146.70 & 62.00 & 3.69 & 3.19 \\
Merc 230 & 22.80 & 4.00 & 140.80 & 95.00 & 3.92 & 3.15 \\
Fiat 128 & 32.40 & 4.00 & 78.70 & 66.00 & 4.08 & 2.20 \\
Honda Civic & 30.40 & 4.00 & 75.70 & 52.00 & 4.93 & 1.61 \\
Toyota Corolla & 33.90 & 4.00 & 71.10 & 65.00 & 4.22 & 1.83 \\
Toyota Corona & 21.50 & 4.00 & 120.10 & 97.00 & 3.70 & 2.46 \\
Fiat X1-9 & 27.30 & 4.00 & 79.00 & 66.00 & 4.08 & 1.94 \\
Porsche 914-2 & 26.00 & 4.00 & 120.30 & 91.00 & 4.43 & 2.14 \\
Lotus Europa & 30.40 & 4.00 & 95.10 & 113.00 & 3.77 & 1.51 \\
Volvo 142E & 21.40 & 4.00 & 121.00 & 109.00 & 4.11 & 2.78 \\
\hline
\multicolumn{6}{l}{Number of cylinders = 6}\\
Mazda RX4 & 21.00 & 6.00 & 160.00 & 110.00 & 3.90 & 2.62 \\
Mazda RX4 Wag & 21.00 & 6.00 & 160.00 & 110.00 & 3.90 & 2.88 \\
Hornet 4 Drive & 21.40 & 6.00 & 258.00 & 110.00 & 3.08 & 3.21 \\
Valiant & 18.10 & 6.00 & 225.00 & 105.00 & 2.76 & 3.46 \\
Merc 280 & 19.20 & 6.00 & 167.60 & 123.00 & 3.92 & 3.44 \\
Merc 280C & 17.80 & 6.00 & 167.60 & 123.00 & 3.92 & 3.44 \\
Ferrari Dino & 19.70 & 6.00 & 145.00 & 175.00 & 3.62 & 2.77 \\
\hline
\multicolumn{6}{l}{Number of cylinders = 8}\\
Hornet Sportabout & 18.70 & 8.00 & 360.00 & 175.00 & 3.15 & 3.44 \\
Duster 360 & 14.30 & 8.00 & 360.00 & 245.00 & 3.21 & 3.57 \\
Merc 450SE & 16.40 & 8.00 & 275.80 & 180.00 & 3.07 & 4.07 \\
Merc 450SL & 17.30 & 8.00 & 275.80 & 180.00 & 3.07 & 3.73 \\
Merc 450SLC & 15.20 & 8.00 & 275.80 & 180.00 & 3.07 & 3.78 \\
Cadillac Fleetwood & 10.40 & 8.00 & 472.00 & 205.00 & 2.93 & 5.25 \\
Lincoln Continental & 10.40 & 8.00 & 460.00 & 215.00 & 3.00 & 5.42 \\
Chrysler Imperial & 14.70 & 8.00 & 440.00 & 230.00 & 3.23 & 5.34 \\
Dodge Challenger & 15.50 & 8.00 & 318.00 & 150.00 & 2.76 & 3.52 \\
AMC Javelin & 15.20 & 8.00 & 304.00 & 150.00 & 3.15 & 3.44 \\
Camaro Z28 & 13.30 & 8.00 & 350.00 & 245.00 & 3.73 & 3.84 \\
Pontiac Firebird & 19.20 & 8.00 & 400.00 & 175.00 & 3.08 & 3.85 \\
Ford Pantera L & 15.80 & 8.00 & 351.00 & 264.00 & 4.22 & 3.17 \\
Maserati Bora & 15.00 & 8.00 & 301.00 & 335.00 & 3.54 & 3.57 \\
\hline
\multicolumn{6}{l}{Line 1 of Message}\\
\multicolumn{6}{l}{Line 2 of Message}\\
\end{tabular}
\end{table}
% latex table generated in R 3.4.1 by xtable 1.8-2 package
% Sat Jul 21 22:43:18 2018
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrr}
\multicolumn{6}{l}{Number of cylinders = 4}\\
\hline
& mpg & cyl & disp & hp & drat & wt \\\hline
Datsun 710 & 22.80 & 4.00 & 108.00 & 93.00 & 3.85 & 2.32 \\
Merc 240D & 24.40 & 4.00 & 146.70 & 62.00 & 3.69 & 3.19 \\
Merc 230 & 22.80 & 4.00 & 140.80 & 95.00 & 3.92 & 3.15 \\
Fiat 128 & 32.40 & 4.00 & 78.70 & 66.00 & 4.08 & 2.20 \\
Honda Civic & 30.40 & 4.00 & 75.70 & 52.00 & 4.93 & 1.61 \\
Toyota Corolla & 33.90 & 4.00 & 71.10 & 65.00 & 4.22 & 1.83 \\
Toyota Corona & 21.50 & 4.00 & 120.10 & 97.00 & 3.70 & 2.46 \\
Fiat X1-9 & 27.30 & 4.00 & 79.00 & 66.00 & 4.08 & 1.94 \\
Porsche 914-2 & 26.00 & 4.00 & 120.30 & 91.00 & 4.43 & 2.14 \\
Lotus Europa & 30.40 & 4.00 & 95.10 & 113.00 & 3.77 & 1.51 \\
Volvo 142E & 21.40 & 4.00 & 121.00 & 109.00 & 4.11 & 2.78 \\
\hline\\
\multicolumn{6}{l}{Number of cylinders = 6}\\
\hline
& mpg & cyl & disp & hp & drat & wt \\\hline
Mazda RX4 & 21.00 & 6.00 & 160.00 & 110.00 & 3.90 & 2.62 \\
Mazda RX4 Wag & 21.00 & 6.00 & 160.00 & 110.00 & 3.90 & 2.88 \\
Hornet 4 Drive & 21.40 & 6.00 & 258.00 & 110.00 & 3.08 & 3.21 \\
Valiant & 18.10 & 6.00 & 225.00 & 105.00 & 2.76 & 3.46 \\
Merc 280 & 19.20 & 6.00 & 167.60 & 123.00 & 3.92 & 3.44 \\
Merc 280C & 17.80 & 6.00 & 167.60 & 123.00 & 3.92 & 3.44 \\
Ferrari Dino & 19.70 & 6.00 & 145.00 & 175.00 & 3.62 & 2.77 \\
\hline\\
\multicolumn{6}{l}{Number of cylinders = 8}\\
\hline
& mpg & cyl & disp & hp & drat & wt \\\hline
Hornet Sportabout & 18.70 & 8.00 & 360.00 & 175.00 & 3.15 & 3.44 \\
Duster 360 & 14.30 & 8.00 & 360.00 & 245.00 & 3.21 & 3.57 \\
Merc 450SE & 16.40 & 8.00 & 275.80 & 180.00 & 3.07 & 4.07 \\
Merc 450SL & 17.30 & 8.00 & 275.80 & 180.00 & 3.07 & 3.73 \\
Merc 450SLC & 15.20 & 8.00 & 275.80 & 180.00 & 3.07 & 3.78 \\
Cadillac Fleetwood & 10.40 & 8.00 & 472.00 & 205.00 & 2.93 & 5.25 \\
Lincoln Continental & 10.40 & 8.00 & 460.00 & 215.00 & 3.00 & 5.42 \\
Chrysler Imperial & 14.70 & 8.00 & 440.00 & 230.00 & 3.23 & 5.34 \\
Dodge Challenger & 15.50 & 8.00 & 318.00 & 150.00 & 2.76 & 3.52 \\
AMC Javelin & 15.20 & 8.00 & 304.00 & 150.00 & 3.15 & 3.44 \\
Camaro Z28 & 13.30 & 8.00 & 350.00 & 245.00 & 3.73 & 3.84 \\
Pontiac Firebird & 19.20 & 8.00 & 400.00 & 175.00 & 3.08 & 3.85 \\
Ford Pantera L & 15.80 & 8.00 & 351.00 & 264.00 & 4.22 & 3.17 \\
Maserati Bora & 15.00 & 8.00 & 301.00 & 335.00 & 3.54 & 3.57 \\
\hline
\multicolumn{6}{l}{Line 1 of Message}\\
\multicolumn{6}{l}{Line 2 of Message}\\
\end{tabular}
\end{table}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.