R: ggfortify: "Objects of type prcomp not supported by auto-repeat"

I am trying to use ggfortify to visualize the PCA results that I used with prcomp.

code example:

iris.pca <- iris[c(1, 2, 3, 4)] 
autoplot(prcomp(iris.pca))  

Error: objects of type prcomp are not supported by auto-retry. Use qplot () or ggplot () instead.

What is strange is that autoplot is specifically designed to handle prcomp-ggplot results, and qplot cannot handle such objects. I am running R version 3.2 and just downloaded ggfortify from github this AM.

Can anyone explain this post?

+4
source share
1 answer

I assume that you did not 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 enter image description here

+5
source

All Articles