Plotting princomp loadings with ggplot

I'm trying to carry out a PCA Analysis on my dataset, and I can plot the loadings out on the basic plot function. But I want to do them on ggplot, but I keep getting this error, "ggplot2 doesn't know how to deal with data of class loadings".

I'm using the princomp function, and I'm plotting my first component against my second component. And I need to colour it on the basis of an external factor which has the same rownames as the dataframe I'm carrying out the pca on. I've tried to do the same thing as this Tutorial with prcomp, but with pca$loadings, but it didnt work. I need to plot my first PC against my second PC in ggplot.

Blockquote

xy <- princomp(iris[,-5])
plot(xy$loadings[,"Comp.1"], xy$loadings[,"Comp.2"], col=iris$Species)
ggplot(xy, aes(x=xy$loadings[,1], y=xy$loadings[,2]))+geom_point()
链接地址: http://www.djcxy.com/p/30898.html

上一篇: 使用ggplot2自定义纯素pca图

下一篇: 用ggplot绘制princomp加载