Use sig() to set the number of significant digits; use digit1() to limit to one digit. See examples.

sig(x, digits = 3, maxex = getOption("pmtables.maxex", NULL), ...)

digit1(x, ...)

rnd(x, digits = 0, ...)

Arguments

x

numeric; value to manipulate.

digits

numeric; number of significant digits.

maxex

numeric; maximum number of significant digits before moving to scientific notation.

...

other arguments that are not used.

Value

A character vector of formatted values.

Details

When x is an integer, x is returned after coercing to character, without further processing.

Examples

sig(1.123455)
#> [1] "1.12"
sig(0.123455)
#> [1] "0.123"
sig(1.123455, digits = 5)
#> [1] "1.1235"
sig(1123, maxex = 3)
#> [1] "1.12e+03"
sig(1123, maxex = 4)
#> [1] "1120"

sig(1L)
#> [1] "1"

digit1(1.234)
#> [1] "1.2"
digit1(1321.123)
#> [1] "1321.1"