Learn R Programming

sjPlot (version 2.4.0)

sjt.fa: Summary of factor analysis as HTML table

Description

Performes a factor analysis on a data frame or matrix and displays the factors as HTML table, or saves them as file. In case a data frame is used as parameter, the Cronbach's Alpha value for each factor scale will be calculated, i.e. all variables with the highest loading for a factor are taken for the reliability test. The result is an alpha value for each factor dimension.

Usage

sjt.fa(data, rotation = c("promax", "varimax"), method = c("ml", "minres",
  "wls", "gls", "pa", "minchi", "minrank"), nmbr.fctr = NULL,
  fctr.load.tlrn = 0.1, title = "Factor Analysis", var.labels = NULL,
  wrap.labels = 40, show.cronb = TRUE, show.comm = FALSE,
  altr.row.col = FALSE, digits = 2, CSS = NULL, encoding = NULL,
  file = NULL, use.viewer = TRUE, no.output = FALSE,
  remove.spaces = TRUE)

Arguments

data

A data frame that should be used to compute a FA, or a fa object.

rotation

Rotation of the factor loadings. May be "varimax" for orthogonal rotation or "promax" for oblique transformation (default). Requires the "GPArotation" package.

method

the factoring method to be used. "ml" will do a maximum likelihood factor analysis (default). "minres" will do a minimum residual (OLS), "wls" will do a weighted least squares (WLS) solution, "gls" does a generalized weighted least squares (GLS), "pa" will do the principal factor solution, "minchi" will minimize the sample size weighted chi square when treating pairwise correlations with different number of subjects per pair. "minrank" will do a minimum rank factor analysis.

nmbr.fctr

Number of factors used for calculating the rotation. By default, this value is NULL and the amount of factors is calculated according to a parallel analysis.

fctr.load.tlrn

Specifies the minimum difference a variable needs to have between factor loadings (components) in order to indicate a clear loading on just one factor and not diffusing over all factors. For instance, a variable with 0.8, 0.82 and 0.84 factor loading on 3 possible factors can not be clearly assigned to just one factor and thus would be removed from the principal component analysis. By default, the minimum difference of loading values between the highest and 2nd highest factor should be 0.1

title

character vector, used as plot title. Depending on plot type and function, will be set automatically. If title = "", no title is printed. For effect-plots, may also be a character vector of length > 1, to define titles for each sub-plot or facet.

var.labels

Character vector with variable names, which will be used to label variables in the output.

wrap.labels

numeric, determines how many chars of the value, variable or axis labels are displayed in one line and when a line break is inserted.

show.cronb

Logical, if TRUE (default), the cronbach's alpha value for each factor scale will be calculated, i.e. all variables with the highest loading for a factor are taken for the reliability test. The result is an alpha value for each factor dimension. Only applies when data is a data frame.

show.comm

Logical, if TRUE, show the communality column in the table.

altr.row.col

Logical, if TRUE, alternating rows are highlighted with a light gray background color.

digits

Numeric, amount of digits after decimal point when rounding estimates and values.

CSS

A list with user-defined style-sheet-definitions, according to the official CSS syntax. For more details, see this package-vignette, or 'Details' in sjt.frq.

encoding

String, indicating the charset encoding used for variable and value labels. Default is NULL, so encoding will be auto-detected depending on your platform (e.g., "UTF-8" for Unix and "Windows-1252" for Windows OS). Change encoding if specific chars are not properly displayed (e.g. German umlauts).

file

Destination file, if the output should be saved as file. If NULL (default), the output will be saved as temporary file and openend either in the IDE's viewer pane or the default web browser.

use.viewer

Logical, if TRUE, the HTML table is shown in the IDE's viewer pane. If FALSE or no viewer available, the HTML table is opened in a web browser.

no.output

Logical, if TRUE, the html-output is neither opened in a browser nor shown in the viewer pane and not even saved to file. This option is useful when the html output should be used in knitr documents. The html output can be accessed via the return value.

remove.spaces

Logical, if TRUE, leading spaces are removed from all lines in the final string that contains the html-data. Use this, if you want to remove parantheses for html-tags. The html-source may look less pretty, but it may help when exporting html-tables to office tools.

Value

Invisibly returns

  • the web page style sheet (page.style),

  • the web page content (page.content),

  • the complete html-output (output.complete),

  • the html-table with inline-css for use with knitr (knitr),

  • the factor.index, i.e. the column index of each variable with the highest factor loading for each factor and

  • the removed.items, i.e. which variables have been removed because they were outside of the fctr.load.tlrn's range.

for further use.

Details

See 'Details' in sjt.frq.

Examples

Run this code
# NOT RUN {
# Data from the EUROFAMCARE sample dataset
library(sjmisc)
library(GPArotation)
data(efc)

# recveive first item of COPE-index scale
start <- which(colnames(efc) == "c82cop1")
# recveive last item of COPE-index scale
end <- which(colnames(efc) == "c90cop9")
# auto-detection of labels
sjt.fa(efc[, start:end])
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab