beer <- read.table("http://www.unt.edu/rss/class/mike/data/beer.txt",header=TRUE, sep="", na.strings="NA", dec=".", strip.white=TRUE) beer2 = beer[,1:7] #just the attribute variables #Installed from the Bioconductor repository. It is a relatively recent package and still under development itself, but given that it came out after this version of R was released you may encounter issues library(pcaMethods) #this package depends on the aroma.light package also #Will estimate missing values with an algorithm related to that used for partial least squares regression, and is actually a nice tool to apply to any dataset for that reason alone fit2=pca(beer2, method = "nipals",nPcs=3) fit2 #complete output fit2@completeObs #the now complete dataset, see the values on AROMA summary(fit2) round(fit2@loadings, 2) slplot(fit2) plotPcs(fit2) #Seems to be unavailable to R 2.6.2 in the lab. Robust PCA, will give warning if missing values are present; alternatively one could first create a robust correlation matrix via cov.rob in the MASS(VR) package fit3=pca(beer2, method = "robustPca",nPcs=3) fit3 #complete output summary(fit3) fit3@loadings round(fit3@loadings,2) #Same, just rounded to two decimal places slplot(fit3) #score/loading plot plotPcs(fit3) #Methods available method=c("svd", "nipals", "bpca", "ppca", "svdImpute", "nlpca", "robustPca") svd: Uses classical prcomp. See documentation for svdPca. nipals: An iterative method capable of handling small amounts of missing values. See documentation for nipalsPca. bpca: An iterative method using a Bayesian model to handle missing values. See documentation for bpca. ppca: An iterative method using a probabilistic model to handle missing values. See documentation for ppca. svdImpute: Uses expectation maximation to perform SVD PCA on incomplete data. See documentation for svdImpute.