gx.rqpca.save: Function to Save PCA Loadings and Scores as .csv files

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/gx.rqpca.save.R

Description

Function to save PCA matrices following computations by functions gx.mva, gx.mva.closed, gx.robmva, gx.robmva.closed or gx.rotate as ‘.csv’ files. By default appropriate files names are generated and the files saved in the Working Directory.

Usage

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

Arguments

save

a saved object from any of functions gx.mva, gx.mva.closed,
gx.robmva, gx.robmva.closed or gx.rotate.

ifload

if ifload = TRUE the PC loadings will be saved. The default is to save the PC loadings.

ifcntrb

if ifcntrb = TRUE the percentage contribution of each variable (communality) to each PC will be saved. The default is not to save this table.

ifscore

if ifscore = TRUE the scores on the PCs will be saved. The default is to save the PC scores.

file

the name of the folder where the files are to be saved, a ‘/’ is appended before the synthesized file name, details of which are displayed on the current device. If no file is specified, the files are saved to the Working Directory.

Details

By default the PCA matrices are saved to the Working Directory with a synthesized file name consisting of the name of the saved object from which the matrices are sourced and an appropriate identifying suffix and ‘.csv’. If a folder name has been provided in file, a ‘/’ is appended prior to the synthesized file name. As each matrix is saved its file name is displayed on the current device. When the saved object is from gx.rotate and is the input object both the original and Varimax loadings and PC scores will be saved by default.

Value

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

Author(s)

Robert G. Garrett

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Make test data available
data(sind.mat2open)

## Estimate and save robust PCA loadings and scores
sind.save <- gx.robmva.closed(sind.mat2open)
gx.rqpca.save(sind.save)

## NOTE: the example below is commented out
## Save PCA scores for future use
## gx.rqpca.save(sind.save, ifcntrb = TRUE, file = "D:\R_work\Project3")

## Clean-up
rm(sind.save)

Example output

Loading required package: MASS
Loading required package: fastICA
  ** Are the data/parts all in the same measurement units? **
  n =  25 	nc =  15 	p =  6 		nc/p =  2.5 
  *** Proceed with Care, Core Size is < 5p ***
  *** Proceed With Great Care, nc =  15 , which is < 3p ***
  Eigenvalues: 1.684 1.315 0.9192 0.6199 0.4622 1.038e-16 
     as %ages: 33.7 26.3 18.4 12.4 9.2 0 
  Score S^2s : 2.45 2.913 18.14 8.072 2.654 3.192e-17 
     as %ages: 7.2 8.5 53 23.6 7.8 0 
  PCA matrices for sind.save 
  Source data matrix: sind.mat2open 

  PC loadings have been saved in:
   /work/tmp/sind.save_PC-loadings.csv 

  PC scores have been saved in:
   /work/tmp/sind.save_PC-scores.csv 

rgr documentation built on May 2, 2019, 6:09 a.m.

Related to gx.rqpca.save in rgr...