signs.Rd
The true minus sign (Unicode 2212) -- neither an em dash, nor an en dash, nor the usual hyphen-minus -- is highly underrated. It makes everything look better!
signs( x, ..., 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") )
x | Numeric vector. |
---|---|
... | 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 UTF-8
character vector
add_plusses
, trim_leading_zeros
, and label_at_zero
are offered for convenience.
The options signs.format
, signs.add.plusses
,
signs.trim.leading.zeros
, and signs.label.at.zero
are set when the package is loaded
to scales::number
, FALSE
, FALSE
, and "none"
,
respectively.
If the package is not loaded and the these options are not otherwise set,
signs
will use those defaults.
label_at_zero
is applied after format
;
that is, if it is "blank"
and you've specified an accuracy of 0.1
,
-0.04
will show as blank.
#> [1] "-5.0" "-4.0" "-3.0" "-2.0" "-1.0" "0.0" "1.0" "2.0" "3.0" "4.0" #> [11] "5.0"signs(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%"signs(x, add_plusses = TRUE)#> [1] "−5.0" "−4.0" "−3.0" "−2.0" "−1.0" "0.0" "+1.0" "+2.0" "+3.0" "+4.0" #> [11] "+5.0"signs(x, add_plusses = TRUE, label_at_zero = "blank")#> [1] "−5.0" "−4.0" "−3.0" "−2.0" "−1.0" "" "+1.0" "+2.0" "+3.0" "+4.0" #> [11] "+5.0"signs(x, add_plusses = TRUE, label_at_zero = "symbol")#> [1] "−5.0" "−4.0" "−3.0" "−2.0" "−1.0" "±0.0" "+1.0" "+2.0" "+3.0" "+4.0" #> [11] "+5.0"signs(x, accuracy = .1, scale = .1, trim_leading_zeros = TRUE)#> [1] "−.5" "−.4" "−.3" "−.2" "−.1" ".0" ".1" ".2" ".3" ".4" ".5"