Recreating APA Manual Table 7.17 in R with apa7

Demonstration of the apa7 package, a flextable extension package
R
APA Style
Author
Affiliation
Published

September 27, 2025

Making tables in APA style (Part 17 of 24)

In this 24-part series, each of the tables in Chapter 7 of the Publication Manual of the American Psychological Association (7th Edition) is recreated with apa7, flextable, easystats, and tidyverse functions.

NoteHighlights
  • Confidence intervals in two columns
  • align_chr with drop0trailing = TRUE for intentionally inconsistent rounding
library(apa7)
library(flextable)
library(ftExtra)
library(tidyverse)
set_flextable_defaults(theme_fun = theme_apa, 
                       font.family = "Times New Roman")

Figure 1

Screenshot of the APA Manual’s Table 7.17

Note that the Estimate column needed inconsistent rounding. Using align_chr with drop0trailing = TRUE and accuracy = .0001, only cells with values in the fourth decimal point will be rounded to .0001.

```{r}
#| label: tbl-717
#| tbl-cap: "Moderator Analysis: Types of Measurement and Study Year"
#| apa-note: 
#|   - "Number of studies = 120, number of
#|     effects = 782, total 
#|     *N* = 52,578. CI = confidence 
#|     interval; *LL* = lower limit; 
#|     *UL* = upper limit."
#|   - "^a ^0 = self-report, 
#|     1 = test. ^b ^ 0 = test, 
#|     1 = grade point average. ^c ^Study 
#|     year was grand centered. ^d ^0 = other, 
#|     1 = yes. ^e ^0 = no, 
#|     1 = yes."

# Make data
d <- tibble(
  effect_type = c(
    "Fixed effects",
    "Fixed effects",
    "Fixed effects",
    "Fixed effects",
    "Fixed effects",
    "Fixed effects",
    "Random effects",
    "Random effects"
  ),
  Effect = c(
    "Intercept",
    "Creativity measurement^&thinsp;a^",
    "Academic achievement measurement^&thinsp;b^",
    "Study year^&thinsp;c^",
    "Goal^&thinsp;d^",
    "Published^&thinsp;e^",
    "Within-study variance",
    "Between-study variance"
  ),
  Estimate = c(0.119, 0.097, -0.039, 2e-04, 
               -0.003, 0.054, 0.009, 0.018),
  SE = c(0.04, 0.028, 0.018, 0.001, 
         0.029, 0.03, 0.001, 0.003),
  `95% CI_*LL*` = c(0.041, 0.042, -0.074, -0.001, 
                    -0.06, -0.005, 0.008, 0.012),
  `95% CI_*UL*` = c(0.198, 0.153, -0.004, 0.002, 
                    0.054, 0.114, 0.011, 0.023),
  p = c(0.003, 0.001, 0.03, 0.76, 
        0.91, 0.07, 9e-04, 9e-04)
) 

# Format data
d_formatted <- d |> 
  mutate(Estimate = align_chr(
    Estimate, 
    accuracy = .0001, 
    drop0trailing = TRUE, 
    trim_leading_zeros = TRUE)) |> 
  mutate(across(c(Estimate:`95% CI_*UL*`), \(x) {
    align_chr(x, 
              accuracy = .001, 
              trim_leading_zeros = TRUE)
  })) |>
  mutate(Effect = hanging_indent(Effect, width = 35)) 

# Make table
d_formatted |> 
  apa_flextable(row_title_column = effect_type) |> 
  align(j = 1) |>
  padding(j = 1, 
          padding.left = c(0, 
                           15, 
                           rep(30, 5), 
                           0, 
                           rep(15, 2))) |> 
  width(width = c(2.5, rep(.8, 5)))
```

Table 1

Moderator Analysis: Types of Measurement and Study Year

Effect

Estimate

SE

95% CI

p

LL

UL

Fixed effects

Intercept

 .119 

.040

 .041

 .198

 .003

Creativity measurement a

 .097 

.028

 .042

 .153

 .001

Academic achievement
    measurement b

−.039 

.018

−.074

−.004

 .03 

Study year c

 .0002

.001

−.001

 .002

 .76 

Goal d

−.003 

.029

−.060

 .054

 .91 

Published e

 .054 

.030

−.005

 .114

 .07 

Random effects

Within-study variance

 .009 

.001

 .008

 .011

<.001

Between-study variance

 .018 

.003

 .012

 .023

<.001

Note. Number of studies = 120, number of effects = 782, total N = 52,578. CI = confidence interval; LL = lower limit; UL = upper limit.
0 = self-report, 1 = test. 0 = test, 1 = grade point average. Study year was grand centered. 0 = other, 1 = yes. 0 = no, 1 = yes.

Citation

BibTeX citation:
@misc{schneider2025,
  author = {Schneider, W. Joel},
  title = {Recreating {APA} {Manual} {Table} 7.17 in {R} with Apa7},
  date = {2025-09-27},
  url = {https://wjschne.github.io/posts/apatables/apa717.html},
  langid = {en}
}
For attribution, please cite this work as:
Schneider, W. J. (2025, September 27). Recreating APA Manual Table 7.17 in R with apa7. Schneirographs. https://wjschne.github.io/posts/apatables/apa717.html