pcaR2: Calculate R-squared for a matrix or principal components

View source: R/pcaR2plot.R

pcaR2R Documentation

Calculate R-squared for a matrix or principal components

Description

Calculate the fraction of variance explained by a predictor (numerical or factor) for each of the columns in a matrix or for each principal component in a prcomp object.

Usage

pcaR2(x, predictor, randomize = 0, comps = NULL, scaled = FALSE)

## S3 method for class 'pcaR2'
plot(x, ...)

Arguments

x

a numeric matrix or object of class prcomp

predictor

a factor or a numeric vector

randomize

how many randomizations should be run

comps

for which PCA components (or for which columns of the numeric matrix) the correlations should be calculated

scaled

whether the data should be scaled

Details

Calculate the fraction of variance explained by a predictor (numerical or factor) for each of the columns in a matrix or for each principal component in a prcomp object.


january3/myfuncs documentation built on Jan. 16, 2025, 8:37 p.m.