/
pretty_ci.Rd
77 lines (60 loc) · 2.59 KB
/
pretty_ci.Rd
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pretty_ci.R
\name{pretty_ci}
\alias{pretty_ci}
\title{Format an estimate, lower and upper confidence intervals into a single character string}
\usage{
pretty_ci(est, lci, uci, string = FALSE, sep = " to ", digits = 2,
inline = FALSE, note = "95\% CI ", replace_bracket = TRUE,
percentage = FALSE)
}
\arguments{
\item{est}{A numeric or character vector of estimates.}
\item{lci}{A numeric or character vector of lower confidence/credible intervals.}
\item{uci}{A numeric or character vector of upper confidence/credible intervals.}
\item{string}{A logicial (defaults to \code{FALSE}) indicating if the estimates are being passed as a string
to \code{est} (formatted as est, lci, uci) or seperately to \code{est}, \code{lci} and \code{uci}.
Supports single estimates or a list/dataframe.}
\item{sep}{A character vector indicating the seperator used between the upper and
lower confidence/credible intervals. The default is ' to '.}
\item{digits}{Integer indicating the number of decimal places to be used.}
\item{inline}{Logical operator indicating whether an explanatory note is required.}
\item{note}{A character vector indicating the explanatory note to be used.}
\item{replace_bracket}{Logical, defaults to \code{TRUE}. Should the leading bracket be automatically
be reinserted in front of the custom note supplied by \code{note}.}
\item{percentage}{A logical (defaults to \code{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.
}
\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.
}
\examples{
## 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)
}
\seealso{
pretty_round pretty_percentage
}