glue_apa_results {papaja} | R Documentation |
Create a New apa_results
Object
Description
Typeset the contents of an object according to the specified expression
strings and create a new or extend an existing apa_results
object.
Usage
glue_apa_results(x = NULL, term_names = NULL, ...)
add_glue_to_apa_results(
...,
est_glue,
stat_glue,
container,
sublist = NULL,
term_names = NULL,
in_paren = FALSE,
est_first = TRUE,
simplify = TRUE
)
Arguments
x |
An environment, list or data frame used to look up values for substitution. |
term_names |
Character. Used as names for the |
... |
[ |
est_glue |
Character. (Named vector of) expressions string(s) to
format. Each string creates a new (named) element in the
|
stat_glue |
Character. (Named vector of) expressions string(s) to
format. Each string creates a new (named) element in the
|
container |
List of class |
sublist |
Character. Name of (new) sub-list in |
in_paren |
Logical. Whether the formatted string is to be reported in
parentheses. If |
est_first |
Logical. Determines in which order |
simplify |
Logical. Determines whether the |
Value
Returns a list of class apa_results
, see apa_print()
.
Examples
# 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 = <<estimate>>, 95% CI $[<<conf.low>>,~<<conf.high>>]$"
, stat_glue = "$t(<<df>>) = <<statistic>>$, $p <<p.value>>$"
, 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 = <<r.squared>>$"
, aic = ""
)
, stat_glue = c(
r2 = "$F(<<df>>, <<df.residual>>) = <<statistic>>$, $p <<add_equals(p.value)>>$"
, aic = "$\\mathrm{AIC} = <<AIC>>$"
)
)