[R] PCA and gglot2

ashz ashz at walla.co.il
Wed Jul 10 22:14:07 CEST 2013


Hi,

Thanks to ssefick for the ggbiplot tip.

It works fine so I submit a general script thats works for future users.

library(ggbiplot)
data<-read.csv("C:/…/MyPCA.csv") 
data1<-data[,1:4] 
my.pca <- prcomp(data1, scale. = TRUE)
my.class<- data$Group  
g <- ggbiplot(my.pca, obs.scale = 1, var.scale = 1,groups = my.class,
ellipse = TRUE, circle = TRUE)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal', 
               legend.position = 'top')
print(g)

BTW
Installation:
library(devtools)
install_github("ggbiplot", "vqv")

you will need to instal before Rtools
(http://cran.r-project.org/bin/windows/Rtools/)

Thanks a lot for the help.




--
View this message in context: http://r.789695.n4.nabble.com/PCA-and-gglot2-tp4671225p4671258.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list