The sign of the loadings and scores generated by PCA is arbitrary. Sometimes
it is convenient to flip them so that all positive loadings/scores become
negative (and vice versa). Sometimes one direction leads to a more natural
interpretation. It is also useful when comparing the results of PCA across
multiple data sets. This function will flip loadings and scores for PCA
analyses carried out by the base R prcomp()
and princomp()
functions and
for the pca_test()
function from this package. If you specify only pc_no
you will flip the loadings and scores for that PC. You can also specify a
variable which you would like to have a positive loading in the resulting
PCA.
Arguments
- pca_obj
The result of a call to
prcomp()
,princomp()
orpca_test
.- pc_no
An integer, indicating which PC is to be flipped.
- flip_var
An optional name of a variable which will become positive in the PC indicated by
pc_no
.