Skip to contents

Extracts factor loadings from factor analyses (either PCA or EFA) conducthed with the psych package, and returns a APA 7th formatted table with the factor loadings and additional metrics (Communality, Uniqueness, Complexity). If desired this table can directly be exported to a Word file (.docx).

Usage

apa_factorLoadings(
  fa_object,
  filepath = NA,
  table_caption = c("Table X", "PCA / EFA Factor Loadings"),
  overwrite = FALSE,
  nod = c(3, 2),
  n.obs = NA,
  cutoff = 0.3,
  orderbyloading = TRUE,
  ...
)

Arguments

fa_object

Either an fa or principal, from which the factor loadings are to be extracted

filepath

(Optional) Path and filename were the APA ready table should be saved, options include the common filetypes .docx (Word), .pptx (Powerpoint), .html (Webpage). Default is filepath = NA. If NA is given, no file will be saved.

table_caption

Takes a character vector. Recommend are the following elements

  • Table + number (e.g., "Table 3")

  • The description, use APA capital case (e.g., "PCA / EFA Factor Loadings")

overwrite

(Optional) Boolean, default is FALSE. When overwrite is FALSE and the files already exists, a serialized version of the filename will be created (i.e., appending _001, or _002). Utilizes serialNext

nod

(Optional) Integer or Integer Vector. Number of Decimals. In case of -1 a simple convention based on sample size is applied for determination of number of decimal points. See ?datscience::get_number_of_decimals. You can also provide an Integer vector, if you want different number of decimals for the correlations and the summary stats. The first integer determines nod for factor loadings, the second for additional stats. E.g., c(2,-1) would give 2 decimals for factor loadings and apply the convention for Complexity, Uniqueness and Communality. Default is nod = c(3,2).
See get_number_of_decimals or?datscience::get_number_of_decimals

n.obs

(Optional), Only required if you want to apply the convention to number of decimals, and did calculate the factor analysis (PCA, EFA) directly on a correlation or covariance matrix.

cutoff

(Optional), Integer, determines the minimum threshold, values below are omitted. Default is cutoff = 0.3.

orderbyloading

(Optional), Boolean, default is orderbyloading = TRUE. If TRUE, items in the table will be sorted by loading on the first factor / component (as in the convention). In some use cases, you rather want to maintain the ordering you used to conduct the analysis (e.g., alphabetical). You can archieve this by providing orderbyloading = FALSE

...

(Optional), Additional arguments that can be passed to format_flextable (e.g., fontsize, font ...) or to serialNext

Value

A flextable object with APA ready correlation table. If a filepath is provided it also creates the respective file (e.g., a word .docx file)

Author

Bjoern Buedenbender

Examples

datscience::apa_factorLoadings(psych::fa(mtcars, nfactors = 2))
#> Loading required namespace: GPArotation
#> Warning: I am sorry, to do these rotations requires the GPArotation package to be installed
#> a flextable object.
#> col_keys: `Item`, `MR1`, `MR2`, `Communality`, `Uniqueness`, `Complexity` 
#> header has 3 row(s) 
#> body has 11 row(s) 
#> original dataset sample: 
#>   Item   MR1   MR2 Communality Uniqueness Complexity
#> 1  cyl 0.964              0.94       0.06       1.01
#> 2 disp 0.945              0.90       0.10       1.01
#> 3  mpg                    0.85       0.15       1.00
#> 4   wt 0.877              0.82       0.18       1.13
#> 5   hp 0.843 0.407        0.88       0.12       1.44