Skip to content

Instantly share code, notes, and snippets.

@njtierney
Created September 18, 2014 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njtierney/77fa7d5f35251dbba96c to your computer and use it in GitHub Desktop.
Save njtierney/77fa7d5f35251dbba96c to your computer and use it in GitHub Desktop.
# turn the data into a correlation matrix
cor(mydata)
# perform the PCA, using `principal`
pca.fit <- principal(mydata,
nfactors = ncol(mydata), # the number of factors = the number of columns in my data
rotate = "varimax", # I want to perform varimax rotation on the factors
residuals = TRUE, # report the residuals
scores = TRUE) # find the component scores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment