Learn R Programming

volker (version 3.0.0)

factor_tab: Get tables with factor analysis results

Description

PCA is performed using add_factors.

[Experimental]

Usage

factor_tab(
  data,
  cols,
  newcols = NULL,
  k = 2,
  method = "pca",
  labels = TRUE,
  clean = TRUE,
  ...
)

Value

A volker list with with three volker tabs: loadings, variances and diagnostics.

Arguments

data

A dataframe.

cols

A tidy selection of item columns.

        If the first column already contains a pca result from \link{add_factors},
        the result is used. Other parameters are ignored.

If there is no pca result yet, it is calculated by \link{add_factors} first.

newcols

Names of the new factor columns as a character vector. Must be the same length as k or NULL. Set to NULL (default) to automatically build a name from the common column prefix, prefixed with "fct_", postfixed with the factor number.

k

Number of factors to calculate. Set to NULL to report eigenvalues for all components up to the number of items and automatically choose k. Eigenvalues and the decision on k are calculated by psych::fa.parallel.

method

The method as character value. Currently, only pca is supported.

labels

If TRUE (default) extracts labels from the attributes, see codebook.

clean

Prepare data by data_clean.

...

Placeholder to allow calling the method with unused parameters from tab_metrics.

Examples

Run this code
library(volker)
ds <- volker::chatgpt

volker::factor_tab(ds, starts_with("cg_adoption"), k = 3)

Run the code above in your browser using DataLab