format01prec

0th

Percentile

Format Numbers in [0,1] with "Precise" Result

Format numbers in [0,1] with “precise” result, notably using "1-.." if needed.

Keywords
print, character
Usage
format01prec(x, digits = getOption("digits"), width = digits + 2,
             eps = 1e-06, ...,
             FUN = function(x, ...) formatC(x, flag = "-", ...))
Arguments
x

numbers in [0,1]; (still works if not)

digits

number of digits to use; is used as FUN(*, digits = digits) or FUN(*, digits = digits - 5) depending on x or eps.

width

desired width (of strings in characters), is used as FUN(*, width = width) or FUN(*, width = width - 2) depending on x or eps.

eps

small positive number: Use '1-' for those x which are in \((1-eps, 1]\). The author has claimed in the last millennium that (the default) 1e-6 is optimal.

optional further arguments passed to FUN(x, digits, width, ...).

FUN

a function used for format()ing; must accept both a digits and width argument.

Value

a character vector of the same length as x.

See Also

formatC, format.pval.

Aliases
  • format01prec
Examples
# NOT RUN {
## Show that format01prec()  does reveal more precision :
cbind(format      (1 - 2^-(16:24)),
      format01prec(1 - 2^-(16:24)))

## a bit more variety
e <- c(2^seq(-24,0, by=2), 10^-(7:1))
ee <- sort(unique(c(e, 1-e)))
noquote(ff <- format01prec(ee))
data.frame(ee, format01prec = ff)
# }
Documentation reproduced from package DPQ, version 0.3-3, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.