| toLatex.numeric | R Documentation |
Formats real numbers, possibly in scientific notation, with a given number of digits after the decimal point. Output can be used in LaTeX math mode, e.g., for printing numbers in a table, where each number has to be printed with the same number of digits after the decimal point, even if the last digits are zeros.
## S3 method for class 'numeric'
toLatex(object, digits = format.info(object)[2],
scientific = format.info(object)[3] > 0, times = "\\cdot", ...)
object |
a numeric vector. |
digits |
number of digits after the decimal point (for the
mantissa if |
scientific |
logical indicating if scientific notation |
times |
character string indicating the LaTeX symbol to be used for the ‘times’ sign. |
... |
unused; for compatibility with |
a character vector of the same length as object,
containing the formatted numbers.
We use digits for round, i.e., round after
the decimal point on purpose, rather than signif()icant
digit rounding as used by print() or
format().
Alain Hauser
pretty10exp which gives expressions
similar to our scientific=TRUE.
toLatex with other methods.
xx <- pi * 10^(-9:9)
format(xx)
formatC(xx)
toLatex(xx) #-> scientific = TRUE is chosen
toLatex(xx, scientific=FALSE)
sapply(xx, toLatex)
sapply(xx, toLatex, digits = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.