displayCI: Generate strings of a confidence interval from a matrix

Description Usage Arguments Value Author(s) Examples

View source: R/displayCI.r

Description

This function serves to display a confidence interval in plain text, taking a vector of length 2 or a d \times 2-matrix containing the confidence limits and given number of digits after the comma. A unit can be additionally supplied.

Usage

1
displayCI(ci, digit = 2, unit = "", text = "none")

Arguments

ci

Vector of length 2 or matrix of size d \times 2, containing the confidence limits.

digit

Number of digits after the comma.

unit

Character string denoting a unit of measurement.

text

Specifies the way how the confidence interval should be displayed.

Value

A character string to be inserted in plain text.

Author(s)

Kaspar Rufibach (maintainer), kaspar.rufibach@gmail.com,
http://www.kasparrufibach.ch

Examples

1
2
3
4
5
6
7
8
9
a <- 0.05
k <- qnorm(p = 1 - a / 2)
x <- 50
n <- 100
wilson.ci <- (x + k ^ 2 / 2) / (n + k ^ 2) + c(-1, 1) * (k * n ^ 0.5) / 
    (n + k ^ 2) * sqrt(x / n * (1 - x / n) + k ^ 2 / (4 * n))
displayCI(wilson.ci)
displayCI(wilson.ci, digit = 1, unit = "cm", text = "none")
displayCI(wilson.ci, digit = 1, unit = "cm", text = "english")

Example output

Loading required package: xtable
[1] "[0.40, 0.60]"
[1] "[0.4cm, 0.6cm]"
[1] "from 0.4cm to 0.6cm"

reporttools documentation built on Oct. 12, 2021, 5:06 p.m.