# ein Beispiel zur Hauptkomponentenanalyse

data("iris")
?iris
iris
# Bem.: sepal = Kelchblatt, petal = Kronblatt/Bluetenblatt

Y <- iris[,1:4] # wir lassen die Artklassifikation weg (ist nicht-numerisch)
Y
pairs(Y)
pairs(Y,col=iris$Species)
hka <- prcomp(Y, center=TRUE)
hka
plot(hka, type='l')
summary(hka)
biplot(hka)

# Fuer bessere Lesbarkeit nochmal, mit Zentrierung und Standardisierung:
hka <- prcomp(Y, center=TRUE, scale=TRUE)
hka
plot(hka, type='l')
summary(hka)
biplot(hka)

plot(hka$x[,1],hka$x[,2],col=iris$Species, pch=20, xlab="Hauptkomponente 1", ylab="Hauptkomponente 2")
