Learn R Programming

rgr (version 1.1.7)

gx.rqpca.print: Function to Display PCA Loadings and Scores

Description

Function to display PCA matrices following computations by functions gx.mva, gx.mva.closed, gx.robmva, gx.robmva.closed or gx.rotate. The user may optionally display the loadings (default), the percentage contribution of the variables to the loadings, i.e. communalities (not default), and the scores on the PCs (default). Optionally the entire table of PC scores may be saved as a .csv file for future use.

Usage

gx.rqpca.print(save, ifload = TRUE, ifcntrb = FALSE, ifscore = TRUE, 
	file = NULL)

Arguments

save
a saved object from any of functions gx.mva, gx.robmva, gx.robmva.closed or gx.rotate.
ifload
if ifload = TRUE the PC loadings are displayed. The default is to display the PC loadings.
ifcntrb
if ifcntrb = TRUE the percentage contribution of each variable (communality) to each PC is displayed. The default is not to display this table.
ifscore
if ifscore = TRUE the scores on the PCs are displayed. The default is to display the PC loadings.
file
the file name for saving the function output in the R working directory, see Details below.

Value

  • The last displayed or saved table, table.rows, is returned and may be saved as an object if required.

Details

By default the PCA loadings and scores on the PCs are displayed on the current device. Optionally the percentage contribution, communality, of each variable to each PC may also be displayed. Additionally a table of cumulative percent contributions, communalities, is displayed to assist in deciding how many components to retain for rotation or further study. When the saved object from gx.rotate is the input object both the original and Varimax loadings and PC scores will be dispslayed by default. The last table displayed by the function may be saved as a csv file in the working directory. Note, the .csv extension is appended in the function. See example below.

See Also

gx.mva, gx.mva.closed, gx.robmva, gx.robmva.closed, gx.rotate.

Examples

Run this code
## Make test data available
data(sind.mat2open)

## Estimate and display robust PCA loadings and scores
sind.save <- gx.robmva.closed(sind.mat2open)
gx.rqpca.print(sind.save, ifcntrb = TRUE)

## Save PCA scores for future use
gx.rqpca.print(sind.save, file = "sind.rob.pca.scores")

## Clean-up
rm(sind.save)

Run the code above in your browser using DataLab