View source: R/tab_dimensionreduction.R
explVar | R Documentation |
The function explVar
calculates the proportion of explained variance
for each principal component (PC, type = "PCA"
) and axis
(type = "PCoA"
).
explVar(d, type = c("PCA", "PCoA"))
d |
|
type |
|
explVar
uses the function prcomp
from the stats
package
to retrieve the explained standard deviation per PC
(type = "PCA"
) and the function cmdscale
from the stats
package to retrieve the explained variation based on eigenvalues per
Axis (type = "PCoA"
).
numeric
vector with the proportion of explained variance
for each PC or Axis
Thomas Naake
x <- matrix(seq_len(100), nrow = 10, ncol = 10,
dimnames = list(seq_len(10), paste("sample", seq_len(10))))
set.seed(1)
x <- x + rnorm(100)
## run for PCA
pca <- dimensionReduction(x = x,
params = list(center = TRUE, scale = TRUE), type = "PCA")[[2]]
explVar(d = pca, type = "PCA")
## run for PCoA
pcoa <- dimensionReduction(x = x,
params = list(method = "euclidean"), type = "PCoA")[[2]]
explVar(d = pcoa, type = "PCoA")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.