I'm using the autoplot function in R (from the ggfortify package) to plot the first two components of a PCA, like this, using the iris dataset as an example:
data<-iris
data_dims<-(data[, 1:4])
data$Species<-as.factor(data$Species)
plot1<-autoplot(prcomp(data_dims, center = TRUE, scale = TRUE), data = data, colour = 'Species', frame = TRUE)
However, I'm wondering if anyone could help me to plot the rotated solution instead? I know to get the rotated solution like this:
pcompanalysis<-prcomp(data, center = TRUE, scale = TRUE)
pcompanalysis_rot <- varimax(pcompanalysis$rotation)
However, I'm unsure how to then use this rotated solution in the autoplot() function?
Edit: Examples are now using the iris dataset to allow reproduction.