signs_format.Rd
Returns a function that will format numeric vectors with proper minus signs.
signs_format( ..., format = getOption("signs.format", scales::number), add_plusses = getOption("signs.add.plusses", FALSE), trim_leading_zeros = getOption("signs.trim.leading.zeros", FALSE), label_at_zero = getOption("signs.label.at.zero", "none") )
... | Other arguments passed on to |
---|---|
format | Any function that takes a numeric vector
and returns a character vector,
such as |
add_plusses | Logical. Should positive values have plus signs? |
trim_leading_zeros | Logical. Should |
label_at_zero | Character. What should be returned
when |
A function that takes a numeric vector
and returns a UTF-8
character vector
See signs
for details.
#> [1] "-5.0" "-4.0" "-3.0" "-2.0" "-1.0" "0.0" "1.0" "2.0" "3.0" "4.0" #> [11] "5.0"f1 <- signs_format() f1(x)#> [1] "−5.0" "−4.0" "−3.0" "−2.0" "−1.0" "0.0" "1.0" "2.0" "3.0" "4.0" #> [11] "5.0"#> [1] "−5%" "−4%" "−3%" "−2%" "−1%" "0%" "1%" "2%" "3%" "4%" "5%"f3 <- signs_format(add_plusses = TRUE) f3(x)#> [1] "−5.0" "−4.0" "−3.0" "−2.0" "−1.0" "0.0" "+1.0" "+2.0" "+3.0" "+4.0" #> [11] "+5.0"f4 <- signs_format(add_plusses = TRUE, label_at_zero = "blank") f4(x)#> [1] "−5.0" "−4.0" "−3.0" "−2.0" "−1.0" "" "+1.0" "+2.0" "+3.0" "+4.0" #> [11] "+5.0"f5 <- signs_format(add_plusses = TRUE, label_at_zero = "symbol") f5(x)#> [1] "−5.0" "−4.0" "−3.0" "−2.0" "−1.0" "±0.0" "+1.0" "+2.0" "+3.0" "+4.0" #> [11] "+5.0"f6 <- signs_format(accuracy = .1, scale = .1, trim_leading_zeros = TRUE) f6(x)#> [1] "−.5" "−.4" "−.3" "−.2" "−.1" ".0" ".1" ".2" ".3" ".4" ".5"