Debian Codegraph @

man/toLatex.numeric.Rd

raw
1 \name{toLatex.numeric}
2 \alias{toLatex.numeric}
3 \title{LaTeX or Sweave friendly Formatting of Numbers}
4 \description{
5 Formats real numbers, possibly in scientific notation, with a given
6 number of digits after the decimal point. Output can be used in LaTeX
7 math mode, e.g., for printing numbers in a table, where each number
8 has to be printed with the same number of digits after the decimal
9 point, even if the last digits are zeros.
10 }
11 \usage{
12 \method{toLatex}{numeric}(object, digits = format.info(object)[2],
13 scientific = format.info(object)[3] > 0, times = "\\\\cdot", \dots)
14 }
15 \arguments{
16 \item{object}{a numeric vector.}
17 \item{digits}{number of digits \emph{after the decimal point} (for the
18 mantissa if \code{scientific}). The default behaves the same as \R's
19 \code{\link{format}()}.}
20 \item{scientific}{logical indicating if scientific notation \code{a *
21 10^k} should be used. The default behaves the same as \R's
22 \code{\link{format}()}.}
23 \item{times}{character string indicating the LaTeX symbol to be used for
24 the \sQuote{times} sign.}
25 \item{\dots}{unused; for compatibility with \code{\link{toLatex}}.}
26 }
27 \note{We use \code{digits} for \code{\link{round}}, i.e., round after
28 the decimal point on purpose, rather than \code{\link{signif}()}icant
29 digit rounding as used by \code{\link{print}()} or
30 \code{\link{format}()}.
31 }
32 \value{
33 a \code{\link{character}} vector of the same length as \code{object},
34 containing the formatted numbers.
35 }
36 \author{Alain Hauser% and Martin -- E-mail ? for harvesters
37 }
38 \seealso{
39 \code{\link{pretty10exp}} which gives \code{\link{expression}}s
40 similar to our \code{scientific=TRUE}.
41 \code{\link{toLatex}} with other methods.
42 }
43 \examples{
44 xx <- pi * 10^(-9:9)
45
46 format(xx)
47 formatC(xx)
48
49 toLatex(xx) #-> scientific = TRUE is chosen
50 toLatex(xx, scientific=FALSE)
51
52 sapply(xx, toLatex)
53 sapply(xx, toLatex, digits = 2)
54 }
55 \keyword{misc}