Learn R Programming

sfsmisc (version 1.0-24)

pretty10exp: Nice 10 ** k Label Expressions

Description

Produce nice $a \times 10^k$ expressions to be used instead of the scientific notation "a E".

Usage

pretty10exp(x, drop.1 = FALSE, digits.fuzz = 7)

Arguments

x
numeric vector (e.g. axis tick locations)
drop.1
logical indicating if $1 \times$ should be dropped from the resulting expressions.
digits.fuzz
number of digits to be considered for integer equality; do not change lightly!

Value

  • an expression of the same length as x, with elements of the form a %*% 10 ^ k.

See Also

axTexpr which builds on pretty10exp(); further axis, axTicks.

Examples

Run this code
pretty10exp(-1:3 * 1000)
pretty10exp(-1:3 * 1000, drop.1 = TRUE)
pretty10exp(c(1,2,5,10,20,50,100,200) * 1e3)
stopifnot(identical(pretty10exp(numeric(0)), expression()))
ax <- 10^(-6:0) - 2e-16
pretty10exp(ax, drop.1=TRUE)
## in sfsmisc version <= 1.0-16, no 'digits',
## i.e., implicitly had  digits := #{double precision digits} ==
(dig. <- .Machine$double.digits * log10(2)) # 15.95
pretty10exp(ax, drop.1=TRUE, digits= dig.)  # ``ugly''

Run the code above in your browser using DataLab