my.pca <- function(dat.feature)
{
## Purpose: Principal Component Analysis
## Arguments:
## dat.feature: a data feature matrix, where each column is a feature vector.
## Return: PCA plots and result.
## Author: Feiming Chen, Date: 15 Feb 2017, 09:59
## ________________________________________________
p <- prcomp(dat.feature)
plot(p, main = "Scree Plot", xlab = "Principal Components")
dev.new()
biplot(p)
print(summary(p))
invisible(p)
}
if (F) { # Unit Test
d <- matrix(rnorm(1000), 20)
my.pca(d)
}
No comments:
Post a Comment