## Iris data further analyses #### part 1 data(iris) par(mfrow=c(2,2)) PCA1<-prcomp(iris[,1:4],center=TRUE,scale.=TRUE) irisPCAs <- predict(PCA1, newdata = iris) #head(irisPCAs) #class(irisPCAs) irisPCAs<-as.data.frame(irisPCAs) colours1<-as.numeric(iris[,5])+9 par(mfrow=c(2,2)) plot(irisPCAs$PC1,irisPCAs$PC2,col=colours1) plot(irisPCAs$PC1,irisPCAs$PC3,col=colours1) plot(irisPCAs$PC1,irisPCAs$PC4,col=colours1) plot(irisPCAs$PC2,irisPCAs$PC3,col=colours1) legend(-5.15,1.9,xpd=NA,c("setosa","versicolor","virginica"), pch=1, col=c("red","green","blue")) #### part 2 using scatterplot in car scatterplot(iris$Sepal.Length,iris$Sepal.Width,groups=iris$Species) #### part 2 using scatterplot in car to plot PCAs scatterplot(PCA1$x[,1],PCA1$x[,2])