From 7b0cb49cf48af3a046e5b8c34bbfeb3adbd1d463 Mon Sep 17 00:00:00 2001 From: roosen Date: Mon, 30 Jan 2012 10:26:00 +0000 Subject: [PATCH] Changed "print.result" to "print.results". I had specified the latter in the vignette, so it's probably an easy error to make. Also added a longtable example to xtableGallery.snw. git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@20 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- pkg/NEWS | 5 ++++- pkg/R/print.xtable.R | 4 ++-- pkg/R/toLatex.R | 2 +- pkg/inst/doc/xtableGallery.snw | 32 +++++++++++++++++++++++++++++--- pkg/man/print.xtable.Rd | 4 ++-- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/pkg/NEWS b/pkg/NEWS index a2469ae..97aa43f 100644 --- a/pkg/NEWS +++ b/pkg/NEWS @@ -3,8 +3,11 @@ * 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 + * Added "print.results" argument to "print" that can be used to suppress the printing. + * Added an "is.null()" check on the "table.placement" argument. + * Added an example of header and footer specification with longtable + to the vignette. 1.6-0 (2011-10-07) * Allow "table*" as a value for "floating.environment" in print.xtable(). diff --git a/pkg/R/print.xtable.R b/pkg/R/print.xtable.R index 9cc6208..2d74267 100644 --- a/pkg/R/print.xtable.R +++ b/pkg/R/print.xtable.R @@ -44,7 +44,7 @@ print.xtable <- function( sanitize.colnames.function=sanitize.text.function, math.style.negative=FALSE, html.table.attributes="border=1", - print.result=TRUE, + print.results=TRUE, ...) { # Claudio Agostinelli dated 2006-07-28 hline.after # 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 @@ -420,7 +420,7 @@ print.xtable <- function( result <- result + ETABLE } result <- sanitize.final(result) - if (print.result){ + if (print.results){ print(result) } diff --git a/pkg/R/toLatex.R b/pkg/R/toLatex.R index 3a2ba58..ceb8320 100644 --- a/pkg/R/toLatex.R +++ b/pkg/R/toLatex.R @@ -31,7 +31,7 @@ toLatex.xtable <- function(object, ...){ dotArgs <- list(...) dotArgs$x <- object dotArgs$type <- "latex" - dotArgs$print.result <- FALSE + dotArgs$print.results <- FALSE z <- do.call("print.xtable", dotArgs) z <- strsplit(z, split="\n")[[1]] diff --git a/pkg/inst/doc/xtableGallery.snw b/pkg/inst/doc/xtableGallery.snw index 39eb05e..2298c93 100644 --- a/pkg/inst/doc/xtableGallery.snw +++ b/pkg/inst/doc/xtableGallery.snw @@ -414,6 +414,31 @@ x.big <- xtable(x,label='tabbig', print(x.big,tabular.environment='longtable',floating=FALSE) @ +\subsubsection{Long tables with headers on each page} + +The {\tt add.to.row} argument can be used to display the header +for a long table on each page, and to add a "continued" footer +on all pages except the last page. + +<>= +library(xtable) +x<-matrix(rnorm(1000), ncol = 10) + +addtorow<-list() +addtorow$pos<-list() +addtorow$pos[[1]]<-c(0) +addtorow$command<-c(paste( + "\\hline \n", + " \\endhead \n", + " \\hline \n", + " {\\footnotesize Continued on next page} \n", + " \\endfoot \n", + " \\endlastfoot \n",sep="")) +x.big <- xtable(x, label = "tabbig", + caption = "Example of longtable spanning several pages") +print(x.big, tabular.environment = "longtable", floating = FALSE, +include.rownames=FALSE,add.to.row=addtorow,hline.after=c(-1) ) +@ \subsection{Sideways tables} Remember to insert \verb|\usepackage{rotating}| in your LaTeX preamble. @@ -434,7 +459,7 @@ print(x.small,floating.environment='sidewaystable') \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}. +standard output can be suppressed by specifying {\tt print.results = FALSE}. <<>>= # This will print the output and store it. @@ -444,8 +469,9 @@ x.out <- print(tli.table) x.out2 <- print(tli.table, print.results = FALSE) @ -Formatted output can also be captured without the printing with the -{\tt toLatex} method. +Formatted output can also be captured without printing with the +{\tt toLatex} method. This function returns an object of class +{\tt "Latex"}. <<>>= x.ltx <- toLatex(tli.table) diff --git a/pkg/man/print.xtable.Rd b/pkg/man/print.xtable.Rd index 55ccf42..f11aa7e 100644 --- a/pkg/man/print.xtable.Rd +++ b/pkg/man/print.xtable.Rd @@ -11,7 +11,7 @@ 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", - print.result=TRUE, ...)} + print.results=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"}. @@ -44,7 +44,7 @@ \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{} 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{print.results}{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{ -- 2.39.2