]> git.donarmstrong.com Git - xtable.git/commitdiff
Minor improvements in help pages - describe return value of xalign & co
authorarnima <arnima@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 29 Sep 2014 11:28:41 +0000 (11:28 +0000)
committerarnima <arnima@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 29 Sep 2014 11:28:41 +0000 (11:28 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@56 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/man/formatHelpers.Rd
pkg/man/xtable.Rd

index ab71bf04eb0814d1faffe8f005ad77bb01233969..20480d1032ebdb8eb9425a1d2eac33fb8455398f 100644 (file)
@@ -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}
index 1416c9baa051e1ab05869a429b89a675e9007a41..dacc66af3de6baf4a420aae0ef34fd098fd9aa6d 100644 (file)
@@ -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")