| apa_format_columns | R Documentation |
apa_format_columns() formats the columns of a data frame of results and
renames their headers in APA style, using a set of column_formats().
apa_flextable() calls it when auto_format_columns = TRUE.
apa_format_columns(
data,
column_formats = NULL,
no_format_columns = NULL,
rename_headers = TRUE,
latex_headers = FALSE,
format_separated_headers = TRUE,
sep = "_",
accuracy = NULL
)
data |
data set (data.frame or tibble) |
column_formats |
|
no_format_columns |
Column name or tidyselect function. selected columns are not formatted |
rename_headers |
if |
latex_headers |
if |
format_separated_headers |
if |
sep |
separator for separated headers (default is "_") |
accuracy |
numeric (default: NULL, uses the current default accuracy set with |
Each column is matched by name to a column_format() in column_formats
(e.g., p, SE, beta, or R2). The values of a matched column are
formatted by the format's formatter, and its name is replaced by the
format's markdown header (e.g., beta becomes *β*), or by its LaTeX
header if latex_headers = TRUE. Columns without a format, and columns
named in no_format_columns, are left as they are.
If format_separated_headers = TRUE (default), a column name with a
separator (sep, an underscore by default) is matched by its last part, so
Model 1_R2 is formatted like R2 and becomes Model 1_*R*^2^. In
apa_flextable(), the part before the separator becomes a column spanner.
Format names that contain an underscore themselves (e.g., R2_adjusted) are
matched whole.
A few columns are matched by a pattern or combined:
CI, CI_low, and CI_high (e.g., from parameters::parameters())
become a single column of intervals, with a header such as "95% CI" that
gives the confidence level stored in CI. Prefixed columns are combined
the same way for each column spanner (e.g., Model 1_CI,
Model 1_CI_low, and Model 1_CI_high become Model 1_95% CI). A CI
column without its bounds is left as it is.
If there are t and df_error columns, the degrees of freedom are moved
into the t header (e.g., t(28)), and df_error is dropped.
A column named like t(28) is formatted with the t_df format (and
gets the header t(28)), and one named like 90% CI with the
CI_percent format.
To see the default formats, run column_formats()@get_tibble. The article
Building Tables by Hand
shows how to change them.
tibble
lm(mpg ~ cyl + wt, data = mtcars) |>
parameters::parameters() |>
apa_format_columns() |>
apa_flextable()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.