tex.catwitherror: paste a number with error in tex-ready format

View source: R/tex-utils.R

tex.catwitherrorR Documentation

paste a number with error in tex-ready format

Description

A number with error is converted to a string in tex-ready format like xx(yy) thereby automatically determining the digit at which the error applies.

Usage

tex.catwitherror(x, dx, digits = 1, with.dollar = TRUE, with.cdot = TRUE,
  ...)

Arguments

x

either a single numeric value, or a numeric vector, where the first element is the value and the second is its error

dx

the error. If supplied, it will be printed as the error and the value is the first element of x. If dx is missing, the second element of x, if available, is used as the error. If dx is missing and the length of x is one, only the value is converted to a string without error.

digits

number of error digits

with.dollar

include the tex dollar in the return string or not

with.cdot

replace the "e" in scientific notation by tex-style "cdot" or not

...

arguments to be passed to formatC in case of no error, or to format.errors otherwise

Details

It is strongly recommended to install the errors-package. Otherwise the formatting options are significantly reduced.

The value of the first element of x is properly rounded to its significant digits determined by the values of dx or the second element of x (see above) and digits. Then a tex-ready string is returned.

Value

writes a string to standard output

Author(s)

Carsten Urbach, curbach@gmx.de and Johann Ostmeyer

Examples


tex.catwitherror(x=0.375567, dx=0.001)
tex.catwitherror(x=c(0.375567, 0.001))
## it can be used with apply
x = array(c(0.1187, 0.291, 0.388, 0.011, 0.037, 0.021), dim=c(3,2))
apply(x, 1, tex.catwitherror, digits=2)


hadron documentation built on Sept. 9, 2022, 5:06 p.m.