If you’re (and you should) interested in principal components then take a good look at this. The linked post will take you by hand to do everything from scratch. If you’re not in the mood then the dollowing R functions will help you.
An example.
# Generates sample matrix of five discrete clusters that have
# very different mean and standard deviation values.
z1 <- rnorm(10000, mean=1, sd=1);
z2 <- rnorm(10000, mean=3, sd=3);
z3 <- rnorm(10000, mean=5, sd=5);
z4 <- rnorm(10000, mean=7, sd=7);
z5 <- rnorm(10000, mean=9, sd=9);
mydata <- matrix(c(z1, z2, z3, z4, z5), 2500, 20, byrow=T,
dimnames=list(paste("R", 1:2500, sep=""), paste("C", 1:20, sep="")))
# Performs principal component analysis after scaling the data.
# It returns a list with class "prcomp" that contains five components:
# (1) the standard deviations (sdev) of the principal components,
# (2) the matrix of eigenvectors (rotation),
# (3) the principal component data (x),
# (4) the centering (center) and
# (5) scaling (scale) used.
pca <- prcomp(mydata, scale=T)
Read the rest of this entry »
LinkedIn
Facebook
Youtube
Twitter