formatCI: Format (Confidence) Intervals

Description Usage Arguments Value Author(s) Examples

Description

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.

Usage

1
formatCI(x, digits = 2, unit = "", text = "none")

Arguments

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.

Value

A character vector of formatted (confidence) intervals.

Author(s)

Sebastian Meyer

Examples

 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"

biostatUZH documentation built on May 2, 2019, 6:06 p.m.