"xtableFtable", "print.xtableFtable",
"toLatex.xtable",
"autoformat", "xalign", "xdigits", "xdisplay",
- "sanitize", "sanitize.numbers", "sanitize.final")
+ "sanitize", "sanitize.numbers", "sanitize.final", "as.is", "as.math")
S3method("print", "xtable")
S3method("print", "xtableMatharray")
tables from the spatial econometrics packages, spdep, splm, and
sphet.
* Extracted sanitize functions from print.xtable as stand-alone
- functions, and exported them.
+ functions, and exported them. Added helper functions as.is and
+ as.math for assistance with sanitization (supplied by Stefan
+ Edwards <sme@iysik.com> in Feature Request #5303).
* Added option to produce math style exponents when sanitizing
- numbers, as suggested by Don Armstrong (don@donarmstrong.com), who
+ numbers, as suggested by Don Armstrong <don@donarmstrong.com>, who
also provided code
* Fixed bug #6907. Warning was created when the data frame as no
rows for type is 'html'. Added a test to create the matrix
Loehnert, which was to replace { and } by \begingroup and
\endgroup respectively as the delimiters when size was to changed
in a table.
-
+ * Added functions xtableList and print.xtableList to produce
+ composite tables consisting of a number of subtables.
+ * Added xtableFtable and print.xtableFtable to format flat tables
+ produced by ftable. Included examples in the xtable gallery.
+ * Produced new vignettes: 'The xtableList Gallery' to illustrate
+ xtableList and print.xtableList; and 'The Other Packages Gallery'
+ to illustrate methods for classes of objects from other packages.
1.8-0
* autoformat, xalign, xdigits, xdisplay from Arni Magnusson, added
return(str)
}
}
+
+### Some trivial helper functions
+### Suggested by Stefan Edwards, sme@iysik.com
+### Helper function for disabling sanitizing
+as.is <- function(str) {str}
+
+### Helper function for embedding names in a math environment
+as.math <- function(str, ...) { paste0('$',str,'$', ...) }
NA.string = getOption("xtable.NA.string", ""),
only.contents = getOption("xtable.only.contents", FALSE),
add.to.row = getOption("xtable.add.to.row", NULL),
- sanitize.text.function = getOption("xtable.sanitize.text.function",
- function(x){x}),
+ sanitize.text.function = getOption("xtable.sanitize.text.function", as.is),
sanitize.rownames.function = getOption("xtable.sanitize.rownames.function",
sanitize.text.function),
sanitize.colnames.function = getOption("xtable.sanitize.colnames.function",
print.xtable(fmtFtbl, hline.after = hline.after,
include.rownames = FALSE, include.colnames = FALSE,
booktabs = booktabs,
- sanitize.text.function = function(x){x})
+ sanitize.text.function = as.is)
} else {
stop("print.xtableFtable not yet implemented for this type")
}
\alias{sanitize}\r
\alias{sanitize.numbers}\r
\alias{sanitize.final}\r
+\alias{as.is}\r
+\alias{as.math}\r
\r
\title{\r
Sanitization Functions\r
sanitize.numbers(str, type, math.style.negative = FALSE,\r
math.style.exponents = FALSE)\r
sanitize.final(str, type)\r
+as.is(str)\r
+as.math(str, ...)\r
}\r
\r
\arguments{\r
for 5e5. If \code{"UTF-8"} or \code{"UTF-8"}, then use UTF-8 to\r
approximate the LaTeX typsetting for 5e5.\r
Default value is \code{FALSE}.}\r
+ \item{\dots}{Additional arguments. Character strings or character\r
+ vectors.}\r
}\r
\details{\r
\r
effect. When \code{type} is \code{"html"}, multiple spaces are\r
replaced by a single space and occurrences of \code{' align="left"'}\r
are eliminated.\r
+\r
+ \code{as.is} and \code{as.math} are trivial helper functions to\r
+ disable sanitizing and to insert a some mathematics in a string\r
+ respectively.\r
}\r
\value{\r
Returns the sanitized character object.\r
Swinton <jonathan@swintons.net>, Uwe Ligges\r
<ligges@statistik.uni-dortmund.de>, and probably David B. Dahl\r
<dahl@stat.byu.edu>.\r
+ \code{as.is} and \code{as.math} suggested and provided by Stefan\r
+ Edwards <sme@iysik.com>.\r
}\r
\r
\examples{\r
-\r
insane <- c("&",">", ">","_","\%","$","\\\\","#","^","~","{","}")\r
names(insane) <- c("Ampersand","Greater than","Less than",\r
"Underscore","Percent","Dollar",\r
sanitize.numbers(x, "latex", TRUE)\r
sanitize.numbers(x*10^(10), "latex", TRUE, TRUE)\r
sanitize.numbers(x, "html", TRUE, TRUE)\r
+as.is(insane)\r
+as.math("x10^10", ": mathematical expression")\r
}\r
\r
\keyword{print }\r
NA.string = getOption("xtable.NA.string", ""),
only.contents = getOption("xtable.only.contents", FALSE),
add.to.row = getOption("xtable.add.to.row", NULL),
- sanitize.text.function = getOption("xtable.sanitize.text.function",
- function(x){x}),
+ sanitize.text.function = getOption("xtable.sanitize.text.function", as.is),
sanitize.rownames.function = getOption("xtable.sanitize.rownames.function",
sanitize.text.function),
sanitize.colnames.function = getOption("xtable.sanitize.colnames.function",
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}, i.e. do not add commands.}
- \item{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
- \code{sanitize.text.function} is not \code{NULL}, 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}.}
+ \item{sanitize.text.function}{Since the table entries are counts no
+ sanitization is necessary. The default is \code{as.is}, which is the
+ function which makes no changes. This also applies to the labels for
+ the row and column variables since these are also part of the table
+ which is printed using a call to \code{print.xtable}.}
\item{sanitize.rownames.function}{Like the
\code{sanitize.text.function}, but applicable to row names.
The default uses the \code{sanitize.text.function}. }
...)\r
}\r
\arguments{\r
- \item{x}{For \code{xtableList}, a list of \R objects all of the same\r
- class, being a class found among \code{methods(xtable)}.\r
+ \item{x}{\r
+ For \code{xtableList}, a list of \R objects all of the same class,\r
+ being a class found among \code{methods(xtable)}. The list may also\r
+ have attributes \code{"subheadings"} and \code{"message"}. The\r
+ attribute \code{"subheadings"} should be a character vector of the\r
+ same length as the list \code{x}. The attribute \code{"message"}\r
+ should be a character vector of any length.\r
For \code{print.xtableList}, an object of class \code{xtableList}\r
produced by a call to \code{xtableList}.}\r
\item{caption}{Character vector of length 1 or 2 containing the\r
\item{\dots}{Additional arguments. (Currently ignored.)}\r
}\r
\details{\r
-%% ~~ If necessary, more details than the description above ~~\r
+ \code{xtableList} produces an object suitable for printing using\r
+ \code{print.xtableList}.\r
+\r
+ The elements of the list \code{x} supplied to \code{xtableList} must\r
+ all have the same structure. When these list items are submitted to\r
+ \code{xtable} the resulting table must have the same number of columns\r
+ with the same column names and type of data.\r
+\r
+ The values supplied to arguments \code{digits} and \code{display},\r
+ must be composed of elements as specified in those same arguments for\r
+ the function \code{\link{xtable}}. See the help for\r
+ \code{\link{xtable}} for details.\r
+\r
+ \code{print.xtableList} produces tables in two different formats\r
+ depending on the value of \code{col.names.format}. If\r
+ \code{col.names.format = "single"}, the resulting table has only a\r
+ single heading row. If \code{col.names.format = "multiple"} there is a\r
+ heading row for each of the subtables making up the complete table.\r
+\r
+ By default if \code{col.names.format = "single"}, there are horizontal\r
+ lines above and below the heading row, and at the end of each\r
+ subtable. If \code{col.names.format = "multiple"}, there are\r
+ horizontal lines above and below each appearance of the heading row,\r
+ and at the end of each subtable.\r
+\r
+ If \code{"subheadings"} is not \code{NULL}, the individual elements of\r
+ this vector (which can include newlines \verb{\\n}) produce a heading\r
+ line or lines for the subtables. When \code{col.names.format =\r
+ "multiple"} these subheadings appear \emph{above} the heading rows.\r
+\r
+ If \code{"message"} is not \code{NULL} the vector produces a line or\r
+ lines at the end of the table.\r
+\r
+ Consult the vignette \sQuote{The \code{xtableList} Gallery} to see\r
+ the behaviour of these functions.\r
+\r
+ Note that at present there is no code for \code{type = "html"}.\r
}\r
\value{\r
-%% ~Describe the value returned\r
-%% If it is a LIST, use\r
-%% \item{comp1 }{Description of 'comp1'}\r
-%% \item{comp2 }{Description of 'comp2'}\r
-%% ...\r
+ \code{xtableList} produces an object of class\r
+ \code{"xtableList"}. An object of this class is a list of\r
+ \code{"xtable"} objects with some additional attributes. Each element\r
+ of the list can have a \code{"subheading"} attribute. The list can\r
+ also have a \code{"message"} attribute.\r
+\r
+ \code{print.xtableList} produces a character string containing LaTeX\r
+ markup which produces a nicely formatted table comprised of subtables,\r
+ when included in a LaTeX document.\r
}\r
\author{\r
David Scott \email{d.scott@auckland.ac.nz}.\r
\seealso{\r
\code{\link{xtable}}, \code{\link{caption}}, \code{\link{label}},\r
\code{\link{align}}, \code{\link{digits}}, \code{\link{display}},\r
- \code{\link{formatC}}\r
+ \code{\link{formatC}}, \code{\link{print.xtable}}.\r
}\r
\examples{\r
+data(mtcars)\r
+mtcars <- mtcars[, 1:6]\r
+mtcarsList <- split(mtcars, f = mtcars$cyl)\r
+attr(mtcarsList, "subheadings") <- paste0("Number of cylinders = ",\r
+ names(mtcarsList))\r
+attr(mtcarsList, "message") <- c("Line 1 of Message",\r
+ "Line 2 of Message")\r
+xList <- xtableList(mtcarsList)\r
+print.xtableList(xList)\r
+print.xtableList(xList, colnames.format = "multiple")\r
}\r
\keyword{ print }\r