]> git.donarmstrong.com Git - xtable.git/blob - pkg/man/formatHelpers.Rd
xalign, xdigits, xdisplay from Arni Magnusson (arnima@hafro.is) added along with...
[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 \code{xtable} alignment, appropriate number of
8   digits, or display type for a vector, or each column of a matrix or
9   data frame.
10 }
11 \usage{
12 xalign(x, pad = TRUE)
13 xdigits(x, pad = TRUE, zap = getOption("digits"))
14 xdisplay(x, pad = TRUE)
15 }
16 \arguments{
17   \item{x}{a vector, matrix, or data frame.}
18   \item{pad}{when \code{x} is two-dimensional, \code{pad = TRUE} inserts
19     an extra \code{"l"} for the row names.}
20   \item{zap}{the number of digits passed to \code{zapsmall}.}
21   
22 }
23 \value{
24   A character or a vector of characters, specifying the suggested
25   alignment, number of digits or display type.
26 }
27 \author{Arni Magnusson.}
28 \seealso{
29   \code{\link{xtable}}.
30 }
31 \examples{
32 ## Vector
33 xalign(precip)
34 xdigits(precip)
35 xdisplay(precip)
36
37 ## Data frame
38 head(mtcars)
39 xalign(mtcars, pad = FALSE)
40 xalign(mtcars, pad = TRUE)
41 xtable(mtcars, align = xalign(mtcars))
42 xdigits(mtcars, pad = FALSE)
43 xdigits(mtcars, pad = TRUE)
44 xtable(mtcars, digits = xdigits(mtcars))
45 xdisplay(mtcars, pad = FALSE)
46 xdisplay(mtcars, pad = TRUE)
47 xtable(mtcars, display = xdisplay(mtcars))
48
49 ## Postprocessing an xtable
50 state <- xtable(state.x77)
51 align(state) <- xalign(state)
52 digits(state) <- xdigits(state)
53 display(state) <- xdisplay(state)
54 }
55 \keyword{array}
56 \keyword{print}