From: arnima Date: Mon, 29 Sep 2014 11:28:41 +0000 (+0000) Subject: Minor improvements in help pages - describe return value of xalign & co X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9c99db75b6817ad1db81ca3755cdd5454d404ff1;hp=e57ea6c724a839cbda79e9b27bb52b1b7e8c8d80;p=xtable.git Minor improvements in help pages - describe return value of xalign & co git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@56 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- diff --git a/pkg/man/formatHelpers.Rd b/pkg/man/formatHelpers.Rd index ab71bf0..20480d1 100644 --- a/pkg/man/formatHelpers.Rd +++ b/pkg/man/formatHelpers.Rd @@ -4,9 +4,8 @@ \alias{xdisplay} \title{Suggest Appropriate Formatting} \description{ - Suggest an appropriate \code{xtable} alignment, appropriate number of - digits, or display type for a vector, or each column of a matrix or - data frame. + Suggest an appropriate alignment, number of digits, and display type + for \code{xtable}. } \usage{ xalign(x, pad = TRUE) @@ -15,18 +14,23 @@ xdisplay(x, pad = TRUE) } \arguments{ \item{x}{a vector, matrix, or data frame.} - \item{pad}{when \code{x} is two-dimensional, \code{pad = TRUE} inserts - an extra code for the row names: \code{"l"} alignment , \code{0} - digits, and \code{"s"} display.} + \item{pad}{whether to format row names, when \code{x} is + two-dimensional.} \item{zap}{the number of digits passed to \code{zapsmall}.} } \value{ - A character or a vector of characters, specifying the suggested - alignment, number of digits, or display type. + \code{xalign} returns a character vector consisting of \code{"l"} and + \code{"r"} elements, for left/right alignment. + + \code{xdigits} returns an integer vector. + + \code{xdisplay} returns a character vector of \code{"d"}, \code{"f"}, + and \code{"s"} elements, for integer/double/string display. } \author{Arni Magnusson.} \seealso{ - \code{\link{xtable}}. + \code{\link{xtable}}, \code{\link{align}}, \code{\link{digits}}, + \code{\link{display}} } \examples{ ## Vector @@ -36,23 +40,20 @@ xdisplay(precip) ## Data frame head(mtcars) -xalign(mtcars, pad = FALSE) -xalign(mtcars, pad = TRUE) -xtable(mtcars, align = xalign(mtcars)) - xdigits(mtcars, pad = FALSE) xdigits(mtcars, pad = TRUE) -xtable(mtcars, digits = xdigits(mtcars)) +xalign(mtcars) +xdisplay(mtcars) -xdisplay(mtcars, pad = FALSE) -xdisplay(mtcars, pad = TRUE) -xtable(mtcars, display = xdisplay(mtcars)) +## Autoformat when xtable is created +xtable(mtcars, align = xalign(mtcars), digits = xdigits(mtcars), + display = xdisplay(mtcars)) -## Postprocessing an xtable -state <- xtable(state.x77) -align(state) <- xalign(state) -digits(state) <- xdigits(state) -display(state) <- xdisplay(state) +## Autoformat existing xtable +mt <- xtable(mtcars) +align(mt) <- xalign(mt) +digits(mt) <- xdigits(mt) +display(mt) <- xdisplay(mt) } \keyword{array} \keyword{print} diff --git a/pkg/man/xtable.Rd b/pkg/man/xtable.Rd index 1416c9b..dacc66a 100644 --- a/pkg/man/xtable.Rd +++ b/pkg/man/xtable.Rd @@ -19,7 +19,7 @@ \alias{xtable.zoo} \title{Create Export Tables} \description{ - Function converting an R object to an \code{xtable} object, which can + Convert an R object to an \code{xtable} object, which can then be printed as a LaTeX or HTML table. } \usage{ @@ -88,7 +88,7 @@ xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, depends on the class of \code{x}. For example, \code{aov} objects produce ANOVA tables while \code{data.frame} objects produce a table of the entire data frame. One can optionally provide a caption - (called a title in HTML) or label (called an anchor in HTML), as well + or label (called an anchor in HTML), as well as formatting specifications. Default values for \code{align}, \code{digits}, and \code{display} are class dependent. @@ -105,17 +105,20 @@ xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, attributes \code{align}, \code{digits}, and \code{display}. It is strongly recommened that you set these attributes through the provided replacement functions as they perform validity checks. - } - \value{An object of class \code{"xtable"} which inherits the +} +\value{An object of class \code{"xtable"} which inherits the \code{data.frame} class and contains several additional attributes specifying the table formatting options. } \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}}, +\seealso{ + \code{\link{print.xtable}}, \code{\link{caption}}, \code{\link{label}}, \code{\link{align}}, \code{\link{digits}}, - \code{\link{display}}, \code{\link{formatC}}, \code{\link{methods}} + \code{\link{display}} + + \code{\link{xalign}}, \code{\link{xdigits}}, \code{\link{xdisplay}} } \examples{ @@ -124,13 +127,13 @@ data(tli) ## Demonstrate data.frame tli.table <- xtable(tli[1:20, ]) -digits(tli.table)[c(2, 6)] <- 0 print(tli.table) print(tli.table, type = "html") ## Demonstrate data.frame with different digits in cells tli.table <- xtable(tli[1:20, ]) -digits(tli.table) <- matrix( 0:4, nrow = 20, ncol = ncol(tli)+1 ) +display(tli.table)[c(2,6)] <- "f" +digits(tli.table) <- matrix(0:4, nrow = 20, ncol = ncol(tli)+1) print(tli.table) print(tli.table, type = "html")