R/pretty_per_effect.R
pretty_per_effect.Rd
A function to convert effect estimates into percentage changes for use in line in
publications. It can either convert an effect estimate with lower and upper confidence intervals that
is unformated into a pretty formated percentage or it can convert a pretty_ci
formatted effect size into a pretty formated percentage.
pretty_per_effect(est = NULL, lci = NULL, uci = NULL, string = FALSE, sep = " to ", note = "95% CI ", replace_bracket = TRUE, digits = 0, inline = FALSE, percentage = TRUE, effect_direct = "increase", ...)
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 | Logical, defaults to |
sep | A character vector indicating the seperator used between the upper and lower confidence/credible intervals. The default is ' to '. |
note | A character vector indicating the explanatory note to be used. |
replace_bracket | Logical, defaults to |
digits | Integer indicating the number of decimal places to be used. |
inline | Logical operator indicating whether an explanatory note is required. |
percentage | A logical (defaults to |
effect_direct | A character string indicating the direction of the percentage. Can be specified as "increase" or "decrease" (defaults to "increase"). |
... | Pass additional arguements to |
A pretty formated percentage with confidence intervals
pretty_ci
est <- 1.2 lci <- 1.1 uci <- 1.3 ## As unformated effects pretty_per_effect(est, lci, uci)#> [1] "20% (10% to 30%)"## As formated effects x <- pretty_ci(est, lci, uci, inline = TRUE) pretty_per_effect(x, string = TRUE, inline = TRUE)#> [1] "20% (95% CI 10% to 30%)"## For a decrease pretty_per_effect(x, string = TRUE, inline = TRUE, effect_direct = "decrease")#> [1] "-20% (95% CI -30% to -10%)"## For difference seperations between strings (vectorised) x <- pretty_ci(est, lci, uci, inline = TRUE, sep = ", ") x <- c(x, x) pretty_per_effect(x, string = TRUE, inline = TRUE)#> [1] "20% (95% CI 10% to 30%)" "20% (95% CI 10% to 30%)"## For a decrease pretty_per_effect(x, string = TRUE, inline = TRUE, effect_direct = "decrease")#> [1] "-20% (95% CI -20% to -30%)"## Vectorised (as a string) est <- c(est, 1.1) lci <- c(lci, 1) uci <- c(uci, 1.2) pretty_per_effect(est, lci, uci)#> [1] "20% (10% to 30%)" "10% (0% to 20%)"