Beruflich Dokumente
Kultur Dokumente
# Load Dataframe
grd<-read.csv("marks.csv")
print(cov.grd.center)
# Put rownames and column names to our eigenvectors for easy reading
rownames(egn.grd.center$vectors)=c("Physics","Stats")
colnames(egn.grd.center$vectors)=c("PC-1","PC-2")
# The sum of eigenvalues should be equal to the sum of variance of the data, you
can check that out
print(paste("The Sum of the eigenvalues :",sum(egn.grd.center$values), sep=""))
print(paste("The sum of the variance: ", var(grd.center[,1])
+var(grd.center[,2]),sep=""))
# Let us plot the eigenvectors lines and the centered data points
pc1.slope=egn.grd.center$vectors[2,1]/egn.grd.center$vectors[1,1]
pc2.slope=egn.grd.center$vectors[2,2]/egn.grd.center$vectors[1,2]
plot(grd.center[,1],grd.center[,2], col="red",xlab="Phys",ylab="Stat",sub="Mean
Scaled")
abline(0,pc1.slope, col="blue")
abline(0,pc2.slope, col="green")
# Take the principle components i.e. the eigenvectors in a matrix. Also called
loadings
loadings=egn.grd.center$vectors
# Correlation Biplot
plot(score[,1]/sd[1],score[,2]/sd[2],main="BiPlot",xlab=xlab,ylab=ylab,type="n")
abline(0,0,col="blue")
abline(0,90,col="green")