formatCI | R Documentation |
formatCI
formats (confidence) intervals with limits
either represented as text or math symbols and optionally including a unit.
It is a re-implementation of displayCI
from the
reporttools package, allowing for customization of the text
format as well as element-wise digits
and unit
arguments.
formatCI(x, digits = 2, unit = "", text = "none")
x |
Either a numeric vector of length 2 representing a single interval, or a 2-column matrix of several intervals. |
digits |
The number of digits after the decimal point. |
unit |
A character string denoting a measurement unit. |
text |
Either a character string referring to one of the predefined text styles ("none", "german", "english"), or a character vector of length 3 defining the strings to put before, between, and after the limits. |
A character vector of formatted (confidence) intervals.
Sebastian Meyer
## single interval, default style
formatCI(c(0.9876, 1.2345))
## "[0.99, 1.23]"
## matrix of several intervals
cis <- matrix(c(
0.0123, 0.456,
-10.003, 5.3,
pi, 2*pi
), nrow = 3, ncol = 2, byrow = TRUE)
## use only 1 digit
formatCI(cis, digits = 1)
## "[0.0, 0.5]" "[-10.0, 5.3]" "[3.1, 6.3]"
## with customized numbers of digits and units
formatCI(cis, digits = 1:3, unit = c("cm", "mm", "m"))
## "[0.0cm, 0.5cm]" "[-10.00mm, 5.30mm]" "[3.142m, 6.283m]"
## with a textual representation of the limits
formatCI(cis, text = "english")
## "from 0.01 to 0.46" "from -10.00 to 5.30" "from 3.14 to 6.28"
formatCI(cis, text = c("", " -- ", ""))
## "0.01 -- 0.46" "-10.00 -- 5.30" "3.14 -- 6.28"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.