Skip to contents

The apa7 package generates publication-ready tables in APA style. Pass a fitted model or a data frame to an apa_* function, and you get a table with APA-style numbers, headers, and borders. Most tables also come with a written note that explains abbreviations, tests, and stars.

Installation

Install the released version from CRAN:

Or install the development version from r-universe:

install.packages("apa7", repos = "https://wjschne.r-universe.dev")

Example data

The examples use a study by Garcia et al. (2010), which comes with the psych package. Participants read about a woman who was denied a promotion because of sex discrimination. In the experiment, the vignette was altered such that she protested individually, protested on behalf of women collectively, or did not protest at all. Participants then rated how much they liked her. Their perceptions of how pervasive sexism is were also measured.

library(apa7)

d <- psych::Garcia
d$protest <- factor(d$protest, levels = 0:2,
                    labels = c("None", "Individual", "Collective"))

Regression

Fit a model as usual, and pass it to apa_parameters. apa_flextable(note = TRUE) creates the table and adds the note.

lm(liking ~ protest + sexism, data = d) |>
  apa_parameters() |>
  apa_flextable(note = TRUE)

A regression table in APA style with a note below it.

ANOVA

aov(liking ~ protest, data = d) |>
  apa_anova()

A one-way ANOVA table in APA style.

Descriptive statistics by group

apa_descriptives(d, c(liking, anger, sexism), by = protest)

A table of means and standard deviations for each protest condition.

Correlations

d |>
  dplyr::select(Anger = anger, Liking = liking,
                `Response Appropriateness` = respappr,
                `Perceived Sexism` = sexism) |>
  apa_cor() |>
  apa_flextable(note = TRUE)

A correlation matrix in APA style, with significant correlations starred.

Reliability

Internal consistency of the Big Five scales in the psych package’s bfi data, with reverse-keyed items:

tb <- apa_reliability(
  psych::bfi,
  scales = list(
    Agreeableness = A1:A5,
    Conscientiousness = C1:C5,
    Extraversion = E1:E5,
    Neuroticism = N1:N5,
    Openness = O1:O5
  ),
  reverse = c(A1, C4, C5, E1, E2, O2, O5),
  level = "scales"
) |> 
  apa_flextable(note = TRUE)

Learn more

Reference

Garcia, D. M., Schmitt, M. T., Branscombe, N. R., & Ellemers, N. (2010). Women’s reactions to ingroup members who protest discriminatory treatment: The importance of beliefs about inequality and response appropriateness. European Journal of Social Psychology, 40(5), 733–745. https://doi.org/10.1002/ejsp.644