Print a plus/minus character.

ish(margin = "", x = "", format = NA, margin_format = format,
  parentheses = FALSE, contract = FALSE)

Arguments

margin

The number after the plus/minus. Can be a character.

x

The number, if any, before the plus/minus. Can be a character.

format

Function. If provided, formats x.

margin_format

Function. If provided, formats margin.

parentheses

Logical. Should margin be wrapped in parentheses?

contract

Logical. If x is provided, should spaces be removed?

Value

Character. x plus or minus a margin (UTF-8).

ish uses glue, so you can use curly bracket notation in x and margin, just like with glue.

Examples

library(scales) ish()
#> [1] "±"
ish("5%")
#> ±5%
ish(.05, format = percent_format(accuracy = 1))
#> ±5%
ish( x = 100, margin = .05, margin_format = percent_format(accuracy = 1), parentheses = TRUE )
#> 100 (±5%)
ish( x = 1e3, margin = .05, format = comma, margin_format = percent_format(accuracy = 1), parentheses = TRUE )
#> 1,000 (±5%)
ish(x = 5, margin = 5)
#> 5 ± 5
ish(x = 5, margin = 5, contract = TRUE)
#> 5±5