ifname<- "DataLondonOlympicDecathlon.csv"
alldata <- read.delim(ifname, row.names=1, header=T, sep=",", as.is=TRUE, 
                      strip.white=FALSE)
#[1]------Calculation of average and standard deviation
DataMatrix<- alldata[,-c(1,2)]
scaleData<-scale(DataMatrix)
avav <- attr(scaleData,"scaled:center")
sdsd <- attr(scaleData,"scaled:scale")
nmod1 <- length(avav)
avav
sdsd
#[2]
ifname2<- "DataLondonOlympicDecathron2.csv"
alldata2 <- read.delim(ifname2, row.names=1, header=T, sep=",", as.is=TRUE, 
                       strip.white=FALSE)
DataMatrix2<- alldata2[,-c(1,2)]; DataMatrix2
#[3]------
nmod2 <- dim(DataMatrix2)
DataMatrix2 <- (DataMatrix2-rep(avav,each=nmod2[1]))/rep(sdsd,each=nmod2[1])
#[4]------Multiple regression analysis
DataFrame01<-data.frame(scaleData)
mRegression<-lm(Points~.,data=DataFrame01)
#[5]------Prediction using mRegression model 
prdata2<-(predict(mRegression,newdata = DataMatrix2))*sdsd[1]+avav[1]
prdata2
#[6]------Check of predicted values
sumchk <- rep(0,5)
for(i in 1:nmod2[1]){
sumchk[i] <- sum((mRegression$coefficients*DataMatrix2[i,])[2:nmod1])
sumchk[i] <- (sumchk[i]+mRegression$coefficients[1])*sdsd[1]+avav[1]
}
print(sumchk)