Skip to contents

APA-formatted correlation table

Usage

apa_cor(
  data,
  note = NULL,
  p_value = 0.05,
  digits = 2,
  bold_significant = TRUE,
  significance_note = TRUE,
  output = c("flextable", "gt", "tibble"),
  family = "Times New Roman",
  font_size = 12,
  text_color = "black",
  border_color = "black",
  border_width = 0.5,
  line_spacing = 2,
  summary_functions = list(M = mean, SD = stats::sd),
  ...
)

Arguments

data

data.frame or tibble with variables to be

note

Custom note to appear below table. (Overrides automatic note.)

p_value

p-value needed to be flagged as significant

digits

Number of digits for rounding

bold_significant

bold significant correlations

significance_note

If TRUE, place note at bottom of table that significant correlations are bolded.

output

output type. Can be "flextable" "gt" or "tibble"

family

font family

font_size

font size

text_color

text color

border_color

border color

border_width

border width in pixels

line_spacing

spacing between lines

summary_functions

A named list of functions that summarize data columns (e.g., mean, sd)

...

<data-masking> parameters passed to psych::corTest

Value

flextable, gt, or tibble

Examples

apa_cor(mtcars[, c("mpg", "am", "gear", "carb")], output = "flextable")

Variable

M

SD

1

2

3

4

1. mpg

20.09

6.03

2. am

0.41

0.50

.60

3. gear

3.69

0.74

.48

.79

4. carb

2.81

1.62

−.55

.06

.27

Note. Correlations signficant at p < .05 are bolded.

apa_cor(mtcars[, c("mpg", "am", "gear", "carb")], output = "gt")
Variable M SD 1 2 3 4
1. mpg 20.09 6.03


2. am 0.41 0.50 .60

3. gear 3.69 0.74 .48 .79
4. carb 2.81 1.62 −.55 .06 .27
Note. Correlations significant at p < .05 are bolded.
apa_cor(mtcars[, c("mpg", "am", "gear", "carb")], output = "tibble") #> # A tibble: 4 × 7 #> Variable M SD `1` `2` `3` `4` #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 1. mpg 20.09 6.03 — NA NA NA #> 2 2. am 0.41 0.50 **.60** — NA NA #> 3 3. gear 3.69 0.74 **.48** **.79** — NA #> 4 4. carb 2.81 1.62 **−.55** .06 .27 —