FmtCI.Rd
Format confidence intervals using a flexible template.
FmtCI(x, template = "%s [%s, %s]", ...)
the numerical values, given in the order in which they are used in the template.
character string as template for the desired format. %s are the placeholders for the numerical values.
the dots are passed on to the Format()
function.
a formatted string
x <- c(est=2.1, lci=1.5, uci=3.8)
# default template
FmtCI(x)
#> [1] "2.1000 [1.5000, 3.8000]"
# user defined template (note the double percent code)
FmtCI(x, template="%s (95%%-CI %s-%s)", digits=1)
#> [1] "2.1 (95%-CI 1.5-3.8)"
# in higher datastructures
mci <- tapply(warpbreaks$breaks, warpbreaks$wool, MeanCI)
sapply(mci, FmtCI, digits=1)
#> A B
#> "31.0 [24.8, 37.3]" "25.3 [21.6, 28.9]"