Is there a way to modify the label for the quadratic term in this case?
CodePudding user response:
If you assign the label inside the tbl_regression()
function, you'll see what you want to get.
library(gtsummary)
c("disp", "disp I(disp^2)") %>%
purrr::map(
~ paste("vs", .x, sep = " ~ ") %>%
as.formula() %>%
glm(data = mtcars, family = binomial(link = "logit")) %>%
tbl_regression(
exponentiate = TRUE,
label = list(
disp = "Displacement",
`I(disp^2)` = "Displacement^2"
)
)
) %>%
tbl_merge() %>%
as_kable()
#> ✖ `I(disp^2)` terms have not been found in `x`.
Characteristic | OR | 95% CI | p-value | OR | 95% CI | p-value |
---|---|---|---|---|---|---|
Displacement | 0.98 | 0.96, 0.99 | 0.002 | 0.99 | 0.92, 1.07 | 0.8 |
Displacement^2 | 1.00 | 1.00, 1.00 | 0.8 |
Created on 2022-09-19 with reprex v2.0.2