prettye: Convert scientific notation to pretty expressions

Description Usage Arguments Details Value Author(s) Examples

View source: R/plotutils.R

Description

Converts scientific notation numbers to expressions suitable for pretty printing, by converting an e character to an expression for times-ten-to-the-power-of.

Usage

1

Arguments

x

a character vector

Details

The argument should be a character vector (and is immediately coerced using as.character). The return value is constructed using characters before the ā€˜eā€™ as the mantissa and characters after the ā€˜eā€™ as the exponent. Therefore, any control of the number of digits to be displayed should be performed using e.g. format before calling prettye.

Value

An expression vector. (Generated using sapply with individual expression return values seems to be converted into an expression with multiple elements.)

Author(s)

Toby Johnson Toby.x.Johnson@gsk.com

Examples

1
2
3
4
5
6
p <- 1/(1:10)*10^-(1:10)
plot(1:length(p), -log10(p),
     type = "p", pch = 19, 
     ylim = c(0, max(-log10(p))), las = 1, 
     xlab = "index", ylab = expression(-log[10](P)))
text(1:length(p), -log10(p), prettye(format(p, digits = 3)), pos = 1)

tobyjohnson/gtx documentation built on Aug. 30, 2019, 8:07 p.m.