# Tidy and typeset output
iris_lm <- lm(Sepal.Length ~ Petal.Length + Petal.Width, iris)
tidy_iris_lm <- broom::tidy(iris_lm, conf.int = TRUE)
tidy_iris_lm$p.value <- apa_p(tidy_iris_lm$p.value)
glance_iris_lm <- broom::glance(iris_lm)
glance_iris_lm$p.value <- apa_p(glance_iris_lm$p.value, add_equals = TRUE)
glance_iris_lm$df <- apa_num(as.integer(glance_iris_lm$df))
glance_iris_lm$df.residual <- apa_num(as.integer(glance_iris_lm$df.residual))
# Create `apa_results`-list
lm_results <- glue_apa_results(
x = tidy_iris_lm
, df = glance_iris_lm$df.residual
, est_glue = "$b = <>, 95% CI $[<>,~<>]$"
, stat_glue = "$t(<>) = <>$, $p <>$"
, term_names = make.names(names(coef(iris_lm)))
)
# Add modelfit information
add_glue_to_apa_results(
.x = glance_iris_lm
, container = lm_results
, sublist = "modelfit"
, est_glue = c(
r2 = "$R^2 = <>$"
, aic = ""
)
, stat_glue = c(
r2 = "$F(<>, <>) = <>$, $p <>$"
, aic = "$\\mathrm{AIC} = <>$"
)
)
Run the code above in your browser using DataLab