pcaRotation: Retrieve PCA rotations from prcomp objects

View source: R/pcaPlots.R

pcaRotationR Documentation

Retrieve PCA rotations from prcomp objects

Description

Retrieve PCA rotations from prcomp objects

Usage

pcaRotation(x, choices, offset, reverse = c(FALSE, FALSE))

Arguments

x

An object of prcomp

choices

Integer vector, indices of principal components, default the first two PCs. If missing, NULL or NA, all PCs are returned.

offset

Oither one or more rows's names in the rotation matrix, or indices, or a logical vector. The average of the rows specified by offset is set to zero.

reverse

Logical of the same length as choices or 1 (which will be repeated), indicating whether the sign of values in the indexed axis should be reversed

Examples


testMatrix <- matrix(rnorm(1000), nrow=10)
testPCA <- prcomp(testMatrix)
testPCAscores <- pcaScores(testPCA)

testPCAscores.withOffset <- pcaScores(testPCA, offset=c(1,3,5))
## notice the average of offset-rows are near zero
colMeans(as.matrix(testPCAscores.withOffset)[c(1,3,5),])

testPCAscores.withReverse <- pcaScores(testPCA, reverse=c(TRUE, FALSE))
colMeans(as.matrix(testPCAscores.withReverse)[c(1,3,5),])


bedapub/ribiosPlot documentation built on Sept. 1, 2023, 6:50 p.m.