Package: xtable
-Version: 1.6-0
+Version: 1.6-1
Date: 2011/10/06
Title: Export tables to LaTeX or HTML
Author: David B. Dahl <dahl@stat.tamu.edu>
# NAMESPACE work by Robert Gentleman <rgentlem@fhcrc.org>
# in e-mail on July 30, 2007.
+#
+# Extended by C Roosen, 30/01/2012
+
+importFrom("utils", toLatex)
export("caption<-", "caption", "label", "label<-",
"align<-", "align", "digits<-", "digits", "display<-",
- "display", "xtable")
+ "display", "xtable", "print.xtable", "toLatex.xtable")
S3method("print", "xtable")
+S3method("toLatex", "xtable")
+
S3method("caption<-", "xtable")
S3method("caption", "xtable")
S3method("label", "xtable")
S3method("digits<-", "xtable")
S3method("display<-", "xtable")
S3method("display", "xtable")
+
S3method("xtable", "data.frame")
S3method("xtable", "matrix")
S3method("xtable", "table")
+1.6-1 (NOT YET RELEASED)
+
+ * Added some vectorization code to improve performance.
+ * Added "toLatex" method.
+ * Included "print" in the exported methods in the NAMESPACE file.
+ * Added "print.result" argument to "print" that can be used to
+ suppress the printing.
+
1.6-0 (2011-10-07)
* Allow "table*" as a value for "floating.environment" in print.xtable().
* Fix bug under which multiple logical columns were formatted incorrectly.
sanitize.colnames.function=sanitize.text.function,\r
math.style.negative=FALSE,\r
html.table.attributes="border=1",\r
+ print.result=TRUE,\r
...) {\r
# Claudio Agostinelli <claudio@unive.it> dated 2006-07-28 hline.after\r
# By default it print an \hline before and after the columns names independently they are printed or not and at the end of the table\r
result <- result + ETABLE\r
} \r
result <- sanitize.final(result)\r
- print(result)\r
-\r
+ if (print.result){\r
+ print(result)\r
+ }\r
+ \r
return(invisible(result$text))\r
}\r
\r
--- /dev/null
+### xtable package\r
+###\r
+### Produce LaTeX and HTML tables from R objects.\r
+###\r
+### Copyright 2000-2012 David B. Dahl <dahl@stat.tamu.edu>\r
+###\r
+### Maintained by Charles Roosen <croosen@mango-solutions.com>\r
+###\r
+### This file is part of the `xtable' library for R and related languages.\r
+### It is made available under the terms of the GNU General Public\r
+### License, version 2, or at your option, any later version,\r
+### incorporated herein by reference.\r
+###\r
+### This program is distributed in the hope that it will be\r
+### useful, but WITHOUT ANY WARRANTY; without even the implied\r
+### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
+### PURPOSE. See the GNU General Public License for more\r
+### details.\r
+###\r
+### You should have received a copy of the GNU General Public\r
+### License along with this program; if not, write to the Free\r
+### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,\r
+### MA 02111-1307, USA\r
+\r
+## The generic for toLatex() is declared in the base package "utils"\r
+\r
+toLatex.xtable <- function(object, ...){\r
+ # Initially just capturing the output of print.xtable(). At some\r
+ # point this could be refactored to have print.xtable() call\r
+ # toLatex() instead. - CR, 30/01/2012\r
+ dotArgs <- list(...)\r
+ dotArgs$x <- object\r
+ dotArgs$type <- "latex"\r
+ dotArgs$print.result <- FALSE\r
+ z <- do.call("print.xtable", dotArgs)\r
+\r
+ z <- strsplit(z, split="\n")[[1]]\r
+ class(z) <- "Latex"\r
+ z\r
+}\r
@
\clearpage
+\section{Suppressing Printing}
+By default the {\tt print} method will print the LaTeX or HTML to standard
+output and also return the character strings invisibly. The printing to
+standard output can be supproessed by specifying {\tt print.result = FALSE}.
+
+<<>>=
+# This will print the output and store it.
+x.out <- print(tli.table)
+
+# This will just store the value.
+x.out2 <- print(tli.table, print.results = FALSE)
+@
+
+Formatted output can also be captured without the printing with the
+{\tt toLatex} method.
+
+<<>>=
+x.ltx <- toLatex(tli.table)
+class(x.ltx)
+x.ltx
+@
+
\section{Acknowledgements}
Most of the examples in this gallery are taken from the {\tt xtable} documentation.
\section{R Session information}
include.colnames=TRUE, only.contents=FALSE, add.to.row=NULL,
sanitize.text.function=NULL, sanitize.rownames.function=sanitize.text.function,
sanitize.colnames.function=sanitize.text.function, math.style.negative=FALSE,
- html.table.attributes="border=1", ...)}
+ html.table.attributes="border=1",
+ print.result=TRUE, ...)}
\arguments{
\item{x}{An object of class \code{"xtable"}.}
\item{type}{Type of table to produce. Possible values for \code{type} are \code{"latex"} or \code{"html"}.
\item{sanitize.colnames.function}{Like the \code{sanitize.text.function}, but applicable to column names. The default uses the \code{sanitize.text.function}.}
\item{math.style.negative}{In a LaTeX table, if \code{TRUE}, then use $-$ for the negative sign (as was the behavior prior to version 1.5-3). Default value is \code{FALSE}.}
\item{html.table.attributes}{In an HTML table, attributes associated with the \code{<TABLE>} tag. Default value is \code{border=1}.}
+ \item{print.result}{If \code{TRUE}, the generated table is printed to standard output. Set this to \code{FALSE} if you will just be using the character vector that is returned invisibly.}
\item{...}{Additional arguments. (Currently ignored.)}
}
\details{
--- /dev/null
+\name{toLatex.xtable}
+\alias{toLatex.xtable}
+\title{Convert Table to Latex}
+\description{Function creating a LaTeX representation of an object of class \code{xtable}.}
+\usage{
+ \method{toLatex}{xtable}(object, ...)}
+\arguments{
+ \item{object}{An object of class \code{"xtable"}.}
+ \item{...}{Other arguments to \code{print.xtable}.}
+}
+\details{
+ This function creates a LaTeX representation of an object of class \code{"xtable"}. This is a method for the generic \code{"toLatex"} in the core R package \code{"utils"}.
+}
+\author{Charles Roosen \email{roosen@gmail.com} with contributions and suggestions from many others (see source code).}
+\seealso{\code{\link{print.xtable}}}
+
+\keyword{toLatex}