[R] PCA and gglot2

John Kane jrkrideau at inbox.com
Wed Jul 10 17:09:59 CEST 2013


It looks like you can if I understand properly. Try this
dat1  <-  data.frame(dat1$scores)
dat1$items  <-  rownames(data1)
ggplot(dat1, aes(Comp.1, Comp.2, colour = items)) + geom_point() +
   theme(legend.position="none")


John Kane
Kingston ON Canada


> -----Original Message-----
> From: ashz at walla.co.il
> Sent: Wed, 10 Jul 2013 06:09:00 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] PCA and gglot2
> 
> Hi,
> 
> I was trying as well as looking for an answer without success (a bit
> strange
> since it should be an easy problem) and therefore I will appreciate you
> help:
> 
> My simple script is:
> # Loadings data of 5 columns and 100 rows of data
> data1<-read.csv("C:/…/MyPCA.csv")
> pairs(data1[,1:4])
> pca1 <- princomp(data1[,1:4], score=TRUE, cor=TRUE)
> biplot(pca1)
> 
> The biplot present the data points as numbers. How can I present the data
> point in color (depends on their group-column 5). I was thinking about
> doing
> it using ggplot2 but I can not succeed. Any idea how to do it?
> 
> Thanks
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/PCA-and-gglot2-tp4671225.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list