Use sig() to set the number of significant digits; use digit1() to limit
to one digit. See examples.
numeric; value to manipulate.
numeric; number of significant digits.
numeric; maximum number of significant
digits before moving to scientific notation.
if character, passed to formatC(), but only when
signif(x, digits = digits) is greater than or equal to 10000.
other arguments that are not used.
A character vector of formatted values.
When x is an integer, x is returned after coercing to character, without
further processing.
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(1123, big.mark = ",")
#> [1] "1120"
sig(11234, big.mark = ",")
#> [1] "11,200"
sig(c(1.1,10.1,100.1,1000.1,10000.1), big.mark = ",")
#> [1] "1.10" "10.1" "100" "1000" "10,000"
sig(0)
#> [1] "0.00"
sig(0L)
#> [1] "0"
sig(1L)
#> [1] "1"
digit1(1.234)
#> [1] "1.2"
digit1(1321.123)
#> [1] "1321.1"