Given a numeric matrix which may or may not contain
pc1 standardizes the columns to have mean 0 and variance 1 and
computes the first principal component using
proportion of variance explained by this component is printed, and so
are the coefficients of the original (not scaled) variables. These
coefficients may be applied to the raw data to obtain the first PC.
if specified, the first PC is scaled so that its maximum
The vector of observations with the first PC. An attribute
"coef" is attached to this vector.
"coef" contains the
set.seed(1) x1 <- rnorm(100) x2 <- x1 + rnorm(100) w <- pc1(cbind(x1,x2)) attr(w,'coef')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.