I am trying to use ggfortify to visualize the results of a PCA I did using prcomp.
sample code:
iris.pca <- iris[c(1, 2, 3, 4)]
autoplot(prcomp(iris.pca))
Error: Objects of type prcomp not supported by autoplot. Please use qplot() or ggplot() instead.
What is odd is that autoplot is specifically designed to handle the results of prcomp - ggplot and qplot can't handle objects like this. I'm running R version 3.2 and just downloaded ggfortify off of github this AM.
Can anyone explain this message?
I'm guessing that you didn't load the required libraries, the code below:
library(devtools)
install_github('sinhrks/ggfortify')
library(ggfortify); library(ggplot2)
data(iris)
iris.pca <- iris[c(1, 2, 3, 4)]
autoplot(prcomp(iris.pca))
will work