computePcaNbDims: Number of dimensions for PCA

Description Usage Arguments Details Value See Also Examples

View source: R/sampleCompute.R

Description

Compute the number of dimensions to keep after a Principal Components Analysis, according to a threshold on the cumulative variance.

Usage

1
computePcaNbDims(sdev, pca.variance.cum.min = 0.9)

Arguments

sdev

standard deviation of the principal components (returned from prcomp).

pca.variance.cum.min

minimal cumulative variance to retain.

Details

computePcaNbDims computes the number of dimensions to keep after a Principal Components Analysis, according to a threshold on the cumulative variance

Value

pca.nb.dims number of dimensions kept.

See Also

computePcaSample

Examples

1
2
3
4
5
6
7
8
9
dat <- rbind(matrix(rnorm(100, mean = 0, sd = 0.3), ncol = 2), 
             matrix(rnorm(100, mean = 2, sd = 0.3), ncol = 2), 
             matrix(rnorm(100, mean = 4, sd = 0.3), ncol = 2))
tf <- tempfile()
write.table(dat, tf, sep=",", dec=".")

x <- importSample(file.features=tf, dir.save=tempdir())
res.pca <- computePcaSample(x)
computePcaNbDims(res.pca$pca$sdev)

RclusTool documentation built on Feb. 4, 2020, 5:08 p.m.