Version: 1.7-4
Date: 2014/08/17
Title: Export tables to LaTeX or HTML
-Author: David B. Dahl <dahl@stat.tamu.edu>
+Author: David B. Dahl <dahl@stat.byu.edu>
Maintainer: David Scott <d.scott@auckland.ac.nz>
Description: Coerce data to LaTeX and HTML tables
URL: http://xtable.r-forge.r-project.org/
###\r
### Produce LaTeX and HTML tables from R objects.\r
###\r
-### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>\r
+### Copyright 2000-2013 David B. Dahl <dahl@stat.byu.edu>\r
###\r
### Maintained by David Scott <d.scott@auckland.ac.nz>\r
###\r
###
### Produce LaTeX and HTML tables from R objects.
###
-### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>
+### Copyright 2000-2013 David B. Dahl <dahl@stat.byu.edu>
###
### This file is part of the `xtable' library for R and related languages.
### It is made available under the terms of the GNU General Public
aString.Width <- c(aString.Width,thisWidth)
}
- alignAllowed <- c("l","r","p","c","|","X")
-
+ alignAllowed <- c("l","r","p","c","|","X")
+
if (any( !(aString.Align %in% alignAllowed))) {
warning("Nonstandard alignments in align string")
}
" ( nrow( x )" )
}
} else {
- if( length(value)==1 ) { value <- rep(value, ncol(x)+1) }
+ if( length(value)==1 ) { value <- rep(value, ncol(x)+1) }
if( length( value ) >1 & length( value ) != ncol(x)+1 ) {
stop( "if argument 'digits' is a vector of length more than one, it must have length equal",
" to ", ncol(x)+1, " ( ncol(x) + 1 )" )
###\r
### Produce LaTeX and HTML tables from R objects.\r
###\r
-### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>\r
+### Copyright 2000-2013 David B. Dahl <dahl@stat.byu.edu>\r
###\r
### Maintained by Charles Roosen <croosen@mango-solutions.com>\r
###\r
###
### Produce LaTeX and HTML tables from R objects.
###
-### Copyright 2000-2013 David B. Dahl <dahl@stat.tamu.edu>
+### Copyright 2000-2013 David B. Dahl <dahl@stat.byu.edu>
###
### This file is part of the `xtable' library for R and related languages.
### It is made available under the terms of the GNU General Public
code associated with the supplied object of class \code{xtable}.\r
}\r
\usage{\r
-\method{print}{xtable}(x, \r
+\method{print}{xtable}(x,\r
type = getOption("xtable.type", "latex"),\r
file = getOption("xtable.file", ""),\r
append = getOption("xtable.append", FALSE),\r
only.contents = getOption("xtable.only.contents", FALSE),\r
add.to.row = getOption("xtable.add.to.row", NULL),\r
sanitize.text.function = getOption("xtable.sanitize.text.function", NULL),\r
- sanitize.rownames.function = getOption("xtable.sanitize.rownames.function", \r
+ sanitize.rownames.function = getOption("xtable.sanitize.rownames.function",\r
sanitize.text.function),\r
- sanitize.colnames.function = getOption("xtable.sanitize.colnames.function", \r
+ sanitize.colnames.function = getOption("xtable.sanitize.colnames.function",\r
sanitize.text.function),\r
math.style.negative = getOption("xtable.math.style.negative", FALSE),\r
html.table.attributes = getOption("xtable.html.table.attributes",\r
Default value is \code{TRUE}. }\r
\item{floating.environment}{If \code{floating=TRUE} and\r
\code{type="latex"}, the resulting table uses the specified floating\r
- environment. Possible values include \code{"table"}, \code{"table*"}, \r
+ environment. Possible values include \code{"table"}, \code{"table*"},\r
and other floating environments defined in LaTeX packages.\r
Default value is \code{"table"}.}\r
\item{table.placement}{If \code{floating=TRUE} and\r
\code{tabularx}. Note that table width specification is not\r
supported with the \code{tabular} or \code{longtable} environments. }\r
\item{comment}{If \code{TRUE}, the version and timestamp comment is\r
- included. Default value is \code{TRUE}. } \r
+ included. Default value is \code{TRUE}. }\r
\item{timestamp}{Timestamp to include in LaTeX comment. Set this\r
- to \code{NULL} to exclude the timestamp. Default value is \code{date()}. } \r
+ to \code{NULL} to exclude the timestamp. Default value is \code{date()}. }\r
\item{...}{Additional arguments. (Currently ignored.) }\r
}\r
\details{\r
This function displays or writes to disk the code to produce a table\r
- associated with an object \code{x} of class \code{"xtable"}. \r
+ associated with an object \code{x} of class \code{"xtable"}.\r
The resulting code is either a LaTeX or HTML table, depending on the\r
value of \code{type}. The function also (invisibly) returns a\r
character vector of the results (which can be helpful for\r
Since version 1.4 the non default behavior of \code{hline.after} is\r
changed. To obtain the same results as the previous versions add to\r
the \code{hline.after} vector the vector \code{c(-1, 0, nrow(x))}\r
- where \code{nrow(x)} is the numbers of rows of the object. \r
+ where \code{nrow(x)} is the numbers of rows of the object.\r
\r
From version 1.4-3, all non-numeric columns are sanitized, and all\r
LaTeX special characters are sanitised for LaTeX output. See Section\r
3 of the \code{xtableGallery} vignette for an example of customising\r
the sanitization. From version 1.4-4, the sanitization also applies to\r
column names. To remove any text sanitization, specify\r
- \code{sanitize.text.function=function(x){x}}. \r
- \r
+ \code{sanitize.text.function=function(x){x}}.\r
+\r
From version 1.6-1 the default values for the arguments other than\r
\code{x} are obtainined using \code{getOption()}. Hence the user can\r
set the values once with \code{options()} rather than setting them in\r
arguments. The recommended approach is to specify \code{digits} supply\r
the argument \code{digits} to \code{xtable}, and to specify\r
\code{format} supply the argument \code{display} to \code{xtable}. See\r
- the examples. \r
+ the examples.\r
}\r
\author{\r
- David Dahl \email{dahl@stat.tamu.edu} with contributions and\r
+ David Dahl \email{dahl@stat.byu.edu} with contributions and\r
suggestions from many others (see source code).\r
}\r
\references{\r
Web. \url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=longtab}\r
}\r
\seealso{\r
- \code{\link{xtable}}, \code{\link{caption}}, \code{\link{label}}, \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}}\r
}\r
\r
\examples{\r
\title{String handling functions}
\description{Private functions for conveniently working with strings.}
\usage{
- string(text,file="",append=FALSE)
+ string(text,file="",append=FALSE)
\method{print}{string}(x,...)
\method{+}{string}(x,y)
as.string(x,file="",append=FALSE)
These functions are private functions used by \code{print.xtable}. They are
not intended to be used elsewhere.
}
-\author{David Dahl \email{dahl@stat.tamu.edu} with contributions and suggestions from many others (see source code).}
+\author{David Dahl \email{dahl@stat.byu.edu} with contributions and suggestions from many others (see source code).}
\seealso{\code{\link{print.xtable}}}
\keyword{print}
These functions retrieve or set table attributes of the object \code{x} of class \code{"xtable"}. See
\code{xtable} for a description of the options.
}
-\author{David Dahl \email{dahl@stat.tamu.edu} with contributions and suggestions from many others (see source code).}
+\author{David Dahl \email{dahl@stat.byu.edu} with contributions and suggestions from many others (see source code).}
\seealso{\code{\link{xtable}}, \code{\link{print.xtable}}, \code{\link{formatC}}}
\keyword{print}
\item{...}{Additional arguments. (Currently ignored.)}
}
\details{
-
+
This function extracts tabular information from \code{x} and returns
an object of class \code{"xtable"}. The nature of the table generated
depends on the class of \code{x}. For example, \code{aov} objects
}
\value{An object of class \code{"xtable"} which inherits the
\code{data.frame} class and contains several additional attributes
- specifying the table formatting options.
+ specifying the table formatting options.
}
-\author{David Dahl \email{dahl@stat.tamu.edu} with contributions and
+\author{David Dahl \email{dahl@stat.byu.edu} with contributions and
suggestions from many others (see source code).
}
\seealso{\code{\link{print.xtable}}, \code{\link{caption}},
## Demonstration of "short caption" support.
fm1sc <- aov(tlimth ~ sex + ethnicty + grade, data = tli)
-fm1sc.table <- xtable(fm1sc,
+fm1sc.table <- xtable(fm1sc,
caption = c("ANOVA Model with Predictors Sex, Ethnicity, and Grade",
"ANOVA: Sex, Ethnicity, Grade"))
print(fm1sc.table)
x <- matrix(rnorm(1000), ncol = 10)
x.big <- xtable(x, label = 'tabbig',
caption = 'Example of longtable spanning several pages')
-print(x.big, tabular.environment = 'longtable', floating = FALSE)
+print(x.big, tabular.environment = 'longtable', floating = FALSE)
x <- x[1:30, ]
x.small <- xtable(x, label = 'tabsmall', caption = 'regular table env')
-print(x.small) # default, no longtable
+print(x.small) # default, no longtable
## Demonstration of sidewaystable support.
## Remember to insert \usepackage{rotating} on your LaTeX preamble
-print(x.small, floating.environment = 'sidewaystable')
+print(x.small, floating.environment = 'sidewaystable')
if(require(stats, quietly = TRUE)) {
## Demonstrate prcomp
# print(xtable(pr2))
}
-## Demonstrate include.rownames, include.colnames,
+## Demonstrate include.rownames, include.colnames,
## only.contents and add.to.row arguments
set.seed(2345)
res <- matrix(sample(0:9, size = 6*9, replace = TRUE), ncol = 6, nrow = 9)
include.colnames = TRUE, only.contents = TRUE,
hline.after = c(0, 0, 9, 9))
-## Demonstrate include.rownames, include.colnames,
+## Demonstrate include.rownames, include.colnames,
## only.contents and add.to.row arguments in Rweave files
\dontrun{
\begin{longtable}{
<<results = tex, fig = FALSE>>=
cat(paste(c('c', rep('cc', 34/2-1), 'c'), collapse = '@{\\hspace{2pt}}'))
- @
+ @
}
\hline
\endhead
print(tli.table, booktabs = TRUE)
print(tli.table, booktabs = TRUE, hline.after = c(-1,0))
print(tli.table, booktabs = TRUE, hline.after = NULL)
-print(tli.table, booktabs = TRUE,
+print(tli.table, booktabs = TRUE,
add.to.row = list(pos = list(2), command = c("\\vspace{2mm} \n")))
-print(tli.table, booktabs = TRUE, add.to.row = list(pos = list(2),
+print(tli.table, booktabs = TRUE, add.to.row = list(pos = list(2),
command = c("youhou\n")), tabular.environment = "longtable")
\testonly{
print(temp.table, type = i, file = outFileName,
append = TRUE, caption.placement = "bottom", table.placement = "htb")
}
-}
+}
}
\keyword{file}