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)
#[1]-----
D2<-as.matrix(ddata^2)
ns<-dim(D2)[[1]]
D2i<-apply(D2,1,mean)
aa<-t(matrix(rep(D2i,ns),nrow=ns,ncol=ns))
D2all<-mean(D2)
Z<-(D2-aa-t(aa)+D2all)/(-2)
eig<-eigen(Z)
eval<-eig$values[1:2]; evec<-eig$vectors[,1:2]
xxx<-evec*rep(sqrt(eval),each=nrow(evec))
#[2]-----
plot(xxx,type="n",main="Correlation of contributions",
     xlab="The first axis",ylab="The second axis")
colordata<-factor(classData)
text(xxx,labels=classData,col=unclass(colordata))