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

sig(x, digits = 3, maxex = NULL, ...)

digit1(x, ...)

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

Arguments

x

numeric, value to manipulate

digits

numeric, number of significant digits Default: 3

maxex

numeric, maximum number of significant digits before moving to scientific notation, Default: NULL

...

other arguments that may be passed but not used

Value

character vector of formatted values

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"

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