My ultimate goal is to run a cluster analysis on a data set with > 1 million records. The input variables for the cluster analysis will be the results of a Principal Component Analysis, as well as other variables not included in the PCA, for a total of maybe 10 variables input into the clustering (the variables I input into the PCA were all very highly correlated with one another while the other variables are not so I chose not to include them in the PCA).
#read data mydata <- read.csv('mydata.csv') #import library for robust methods because my data contained outliers library(rrcov) #run robust PCA method called PcaCov pcaR <- PcaCov(~., mydata, na.action=na.omit, center=TRUE, scale = TRUE, k=8) #look at results summary(pcaR) screeplot(pcaR) pcaR@loadings
From the results, I have decided I would like to retain the first three components, which capture ~87% of the total variance in the dataset.
Now I want to extract/save/export these first three components for use in the cluster analysis with my other variables. How do I do this?