Learn R Programming

ribiosPlot (version 1.3.0)

expVar: S3 function expVar to extract explained variance from prcomp and PCAScoreMatrix objects

Description

S3 function expVar to extract explained variance from prcomp and PCAScoreMatrix objects

Usage

expVar(x, choices)

# S3 method for prcomp expVar(x, choices)

# S3 method for PCAScoreMatrix expVar(x, choices)

Value

A numeric vector of variance explained

Arguments

x

A prcomp or PCAScoreMatrix object.

choices

Either missing, or an integer vector of indices, indicating which PCs should be returned.

Methods (by class)

  • expVar(prcomp): Extract explained variance from a prcomp object

  • expVar(PCAScoreMatrix): Extract explained variance from a PCAScoreMatrix object

Methods (by class)

  • prcomp: Extract explained variance from a prcomp object

  • PCAScoreMatrix: Extract explained variance from a PCAScoreMatrix object

Examples

Run this code

myMat <- matrix(rnorm(100), ncol=10)
myPrcomp <- prcomp(myMat)
myPcaScoreMatrix <- pcaScores(myPrcomp, choices=NULL) 
expVar(myPrcomp)
expVar(myPcaScoreMatrix)

expVar(myPrcomp, 1:5)
expVar(myPcaScoreMatrix, 1:5)

Run the code above in your browser using DataLab