R Code - Producing Automated Outputs
R Code - Producing Automated Outputs
#Define the logistic regression model ‘m2’ and use it in the regression table
#Display exponentiated coefficients (odds ratios) in the table
m2 <- glm(am ~ mpg + vs, data=cars, family=binomial)
tbl_regression(m2, exponentiate=TRUE,
label = list(
mpg ~ "Fuel economy (miles per gallon)",
vs ~ "Engine configuration (straight vs v-shaped)"),
intercept = FALSE,
show_single_row = c(vs)
) %>%
modify_header(label = "**Exposure**", estimate = "**OR**", ci = "**95% CI**", p.value = "**P-value**") %>%
modify_footnote(estimate = "OR: Odds ratio", abbreviation = TRUE) %>%
modify_footnote(ci = "CI: Confidence interval", abbreviation = TRUE) %>%
modify_footnote(estimate ~ "Odds ratios for manual transmission according to exposures; exposures were included
simultaneously in the model") %>%
as_flex_table() %>%
flextable::save_as_docx(path="C:/Users/ldw1c13/Documents/Regression Table 2.docx")