]> git.donarmstrong.com Git - xtable.git/blob - pkg/man/formatHelpers.Rd
Vignette: no url package, no \R command, sort LaTeX pkgs, repaginate
[xtable.git] / pkg / man / formatHelpers.Rd
1 \name{xalign}
2 \alias{xalign}
3 \alias{xdigits}
4 \alias{xdisplay}
5 \title{Suggest Appropriate Formatting}
6 \description{
7   Suggest an appropriate alignment, number of digits, and display type
8   for \code{xtable}.
9 }
10 \usage{
11 xalign(x, pad = TRUE)
12 xdigits(x, pad = TRUE, zap = getOption("digits"))
13 xdisplay(x, pad = TRUE)
14 }
15 \arguments{
16   \item{x}{a vector, matrix, or data frame.}
17   \item{pad}{whether to format row names, when \code{x} is
18     two-dimensional.}
19   \item{zap}{the number of digits passed to \code{zapsmall}.}
20 }
21 \value{
22   \code{xalign} returns a character vector consisting of \code{"l"} and
23   \code{"r"} elements, for left/right alignment.
24
25   \code{xdigits} returns an integer vector.
26
27   \code{xdisplay} returns a character vector of \code{"d"}, \code{"f"},
28   and \code{"s"} elements, for integer/double/string display.
29 }
30 \author{Arni Magnusson.}
31 \seealso{
32   \code{\link{xtable}}, \code{\link{align}}, \code{\link{digits}},
33   \code{\link{display}}
34 }
35 \examples{
36 ## Vector
37 xalign(precip)
38 xdigits(precip)
39 xdisplay(precip)
40
41 ## Data frame
42 head(mtcars)
43 xdigits(mtcars, pad = FALSE)
44 xdigits(mtcars, pad = TRUE)
45 xalign(mtcars)
46 xdisplay(mtcars)
47
48 ## Autoformat when xtable is created
49 xtable(mtcars, align = xalign(mtcars), digits = xdigits(mtcars),
50        display = xdisplay(mtcars))
51
52 ## Autoformat existing xtable
53 mt <- xtable(mtcars)
54 align(mt) <- xalign(mt)
55 digits(mt) <- xdigits(mt)
56 display(mt) <- xdisplay(mt)
57 }
58 \keyword{array}
59 \keyword{print}