This function is mainly used for placing in the text fields of Rmarkdown reports.
fmt_ci(
e = numeric(),
l = numeric(),
u = numeric(),
digits = 2,
percent = TRUE,
separator = "-"
)
fmt_pci(
e = numeric(),
l = numeric(),
u = numeric(),
digits = 2,
percent = TRUE,
separator = "-"
)
fmt_pci_df(
x,
e = 3,
l = e + 1,
u = e + 2,
digits = 2,
percent = TRUE,
separator = "-"
)
fmt_ci_df(
x,
e = 3,
l = e + 1,
u = e + 2,
digits = 2,
percent = TRUE,
separator = "-"
)the column of the estimate (defaults to the third column). Otherwise, a number
the column of the lower bound (defaults to the fourth column). Otherwise, a number
the column of the upper bound (defaults to the fifth column), otherwise, a number
the number of digits to show
if TRUE (default), converts the number to percent, otherwise
it's treated as a raw value
what to separate lower and upper confidence intervals with, default is "-"
a data frame
a text string in the format of "e\
cfr <- data.frame(x = 1, y = 2, est = 0.5, lower = 0.25, upper = 0.75)
fmt_pci_df(cfr)
#> [1] "50.00% (CI 25.00-75.00)"
# If the data starts at a different column, specify a different number
fmt_pci_df(cfr[-1], 2, d = 1)
#> [1] "50.0% (CI 25.0-75.0)"
# It's also possible to provide numbers directly and remove the percent sign.
fmt_ci(pi, pi - runif(1), pi + runif(1), percent = FALSE)
#> [1] "3.14 (CI 2.95-4.12)"