create a character column by combining estimate, lower and upper columns. This is similar to tidyr::unite().

unite_ci(
  x,
  col = NULL,
  ...,
  remove = TRUE,
  digits = 2,
  m100 = TRUE,
  percent = FALSE,
  ci = FALSE
)

merge_ci_df(x, e = 3, l = e + 1, u = e + 2, digits = 2)

merge_pci_df(x, e = 3, l = e + 1, u = e + 2, digits = 2)

Arguments

x

a data frame with at least three columns defining an estimate, lower bounds, and upper bounds.

col

the quoted name of the replacement column to create

...

three columns to bind together in the order of Estimate, Lower, and Upper.

remove

if TRUE (default), the three columns in ... will be replaced by col

digits

the number of digits to retain for the confidence interval.

m100

TRUE if the result should be multiplied by 100

percent

TRUE if the result should have a percent symbol added.

ci

TRUE if the result should include "CI" within the braces (defaults to FALSE)

e

the column of the estimate (defaults to the third column). Otherwise, a number

l

the column of the lower bound (defaults to the fourth column). Otherwise, a number

u

the column of the upper bound (defaults to the fifth column), otherwise, a number

Value

a modified data frame with merged columns or one additional column representing the estimate and confidence interval

Examples


fit <- lm(100/mpg ~ disp + hp + wt + am, data = mtcars)
df  <- data.frame(v = names(coef(fit)), e = coef(fit), confint(fit), row.names = NULL)
names(df) <- c("variable", "estimate", "lower", "upper")
print(df)
#>      variable    estimate        lower       upper
#> 1 (Intercept) 0.740647656 -0.774822875 2.256118188
#> 2        disp 0.002702925 -0.002867999 0.008273849
#> 3          hp 0.005274547 -0.001400580 0.011949674
#> 4          wt 1.001303136  0.380088737 1.622517536
#> 5          am 0.155814790 -0.614677730 0.926307310
unite_ci(df, "slope (CI)", estimate, lower, upper, m100 = FALSE, percent = FALSE)
#>      variable         slope (CI)
#> 1 (Intercept) 0.74 (-0.77--2.26)
#> 2        disp 0.00 (-0.00--0.01)
#> 3          hp 0.01 (-0.00--0.01)
#> 4          wt  1.00 (0.38--1.62)
#> 5          am 0.16 (-0.61--0.93)