ifname <- "DataBrandy.csv"
df<-read.delim(ifname, header=T,sep=",",row.names=1,as.is=TRUE,strip.white=FALSE)
classData<-substring(rownames(df), 1, 2)
#[0]scaling
sdata<-scale(df)
#sdata<-df
ddata<-dist(sdata)
mdsdata<-cmdscale(ddata,k=5,eig=TRUE)
#[1]peigen: percent eigen----------------
totaleigen<-sum(mdsdata$eig)
peigen<-mdsdata$eig/totaleigen
neigen<-length(mdsdata$eig)
barplot(peigen,names.arg=1:neigen,ylim=c(0,0.5),main="Sorted order of eigenvalues",
        xlab="Sorted order of principal components",ylab="Eigenvalue")
#[2]-------------------------------------
xaxis<-1; yaxis<-2
plot(mdsdata$points[,xaxis],mdsdata$points[,yaxis],type="n",
     main="Correlation of contributions",xlab="The first axis",ylab="The second axis")
colordata<-factor(classData)
text(mdsdata$points[,xaxis],mdsdata$points[,yaxis],labels=classData,
     col=unclass(colordata))