Description Usage Arguments Value Author(s) Examples
The function 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.
1 |
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 ( |
A character vector of formatted (confidence) intervals.
Sebastian Meyer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ## 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.