Hi all,

I was doing a PCA o the iris data set but when trying to rbind the "Species" column back from the original data set, it turned into 1:3 integers instead of the original ones. I noticed that the original names of the species are of type "integer", but I don't understand why, and how to put them back with the name. That might be important if you have more than 3 species. Then when I plotted I got an error message, here are the codes:

works, but the species name has changed into 1,2,3:

clrs <- c('red','green','blue')
iris.sub=subset(iris, select=-Species)
iris.sub.pca <- prcomp(iris.sub, center=T, retx=T)
iris.bind=cbind(iris.sub.pca$x, iris$Species)
plot(data=iris.bind, PC2~PC1, asp=1, pch=16, xlab='PC1',
ylab='PC2',xlim=c(-5,5),ylim=c(-5,5), col = clrs[iris$Species] )

If I plot like this:

plot(iris.bind$x[,1], iris.bind$x[,2],asp=1,pch=16, xlab='PC1', ylab='PC2',xlim=c
     (-5,5),ylim=c(-5,5), col = clrs[iris$Species] )

I get this error message

Error in iris.bind$x : $ operator is invalid for atomic vectors

Thanks a lot,
Guy







--
Guy Wachsman
Benfey lab, FFSC #4131, Duke
130 Science Drive
27708, Durham, NC
email: gw57@duke.edu


	[[alternative HTML version deleted]]

