This single-function package is designed to be a fast way of creating a correlation matrix from a dataframe that includes the needed variables. It also produces means, standard deviations and NHS significance tests at various levels, with an export function for the clipboard.
It is also a good tool of creating an S3 object that plugs in well into
the papaja: Prepare APA Journal Articles with R Markdown
package, to
produce a correlation table afer the APA manuscript guidelines.
To install the latest (see latest changes below), type the following commands into the R console:
library(devtools)
devtools::install_github("GGLuca/apa.cor")
To create a correlation matrix for the Agreeableness items from the
bfi
dataset (psych
package, 25 Personality items representing 5
factors):
library(tidyverse) # load Tidyverse
library(psych) # load package psych for the `bfi`dataset
library(apa.cor)
bfi %>%
select(A1:A5) %>%
apa.cor()
## M SD 1 2 3 4
## A1 2.41 1.41
## A2 4.80 1.17 -.34**
## A3 4.60 1.30 -.27** .49**
## A4 4.70 1.48 -.15** .34** .36**
## A5 4.56 1.26 -.18** .39** .50** .31**
The function also has an export option export = TRUE
, that copies the
output into the clipboard, for further manipulation such a simple paste
into Microsoft Word.
apa.cor(x, export = TRUE)
Since the function outputs a proper S3 object, it is perfect for integrating it into the papaja package, be it to create html tables or better yet, beautifully formatted PDF files.
library(papaja)
bfi %>%
select(A1:A5) %>%
apa.cor() %>%
apa_table(
.,
, caption = "Variable Means, Standard Deviations, and Correlations Between Agreeableness Items"
, note = "This table was created with apa_table()."
, escape = TRUE
)
Variable Means, Standard Deviations, and Correlations Between Agreeableness Items
M | SD | 1 | 2 | 3 | 4 | |
---|---|---|---|---|---|---|
A1 | 2.41 | 1.41 | ||||
A2 | 4.80 | 1.17 | -.34** | |||
A3 | 4.60 | 1.30 | -.27** | .49** | ||
A4 | 4.70 | 1.48 | -.15** | .34** | .36** | |
A5 | 4.56 | 1.26 | -.18** | .39** | .50** | .31** |
Note. This table was created with apa_table().