pretty_ci: Format an estimate, lower and upper confidence intervals into...

Description Usage Arguments Value See Also Examples

Description

Take numeric/character vectors of the estimate, and upper/lower confidence/credible intervals, round with trailing zeros and format into the required journal style.

Usage

1
2
3
pretty_ci(est, lci, uci, string = FALSE, sep = " to ", digits = 2,
  inline = FALSE, note = "95% CI ", replace_bracket = TRUE,
  percentage = FALSE)

Arguments

est

A numeric or character vector of estimates.

lci

A numeric or character vector of lower confidence/credible intervals.

uci

A numeric or character vector of upper confidence/credible intervals.

string

A logicial (defaults to FALSE) indicating if the estimates are being passed as a string to est (formatted as est, lci, uci) or seperately to est, lci and uci. Supports single estimates or a list/dataframe.

sep

A character vector indicating the seperator used between the upper and lower confidence/credible intervals. The default is ' to '.

digits

Integer indicating the number of decimal places to be used.

inline

Logical operator indicating whether an explanatory note is required.

note

A character vector indicating the explanatory note to be used.

replace_bracket

Logical, defaults to TRUE. Should the leading bracket be automatically be reinserted in front of the custom note supplied by note.

percentage

A logical (defaults to FALSE), which indicates whether the output should be treated as a percentage.

Value

The estimate with formated upper, and lower confidence/credible intervals as a character vector.

See Also

pretty_round pretty_percentage

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
25
26
27
28
## Formating a single confidence interval
pretty_ci(2, lci = 1, uci = 3)

## Formating vectors of confidence intervals
est <- c(0, 1, 100, 300, 21221, 403)
lci <- c(-123, -0.2, 50, 100, 12321, 200)
uci <- c(10, 2, 200, 400, 30122, 500)

pretty_ci(est, lci = lci, uci = uci, sep = '-', digits = 1)

## Use in a dplyr workflow
library(dplyr)

x <- data_frame(est = c(0,1), lci = c(0, 2), uci = c(1, 4))
x <- x %>% mutate(ci = est %>% pretty_ci(lci = lci, uci = uci, sep = ' by ', digits = 0))

## Passing values as a single string
est <- c(0, -1, 1)
pretty_ci(est, string = TRUE)

est <- data.frame(est = c(1,2), lci = c(0, 1), uci = c(2, 3))
pretty_ci(est, string = TRUE)

est <- 98
lci <- 96
uci <- 99

pretty_ci(est, lci, uci, percentage = TRUE)

seabbs/prettypublisher documentation built on May 30, 2019, 10:36 p.m.