Skip to contents

Translate a string where x and dots are interpreted as number place holders, and others as formatting elements.

Usage

format_xx(str)

Arguments

str

(string)
template.

Value

An rtables formatting function.

Examples

test <- list(c(1.658, 0.5761), c(1e1, 785.6))

z <- format_xx("xx (xx.x)")
sapply(test, z)
#> [1] "2 (0.6)"    "10 (785.6)"

z <- format_xx("xx.x - xx.x")
sapply(test, z)
#> [1] "1.7 - 0.6"  "10 - 785.6"

z <- format_xx("xx.x, incl. xx.x% NE")
sapply(test, z)
#> [1] "1.7, incl. 0.6% NE"  "10, incl. 785.6% NE"