x <- c('e1071','caret');for(i in x){if(!require(i,character.only=T)){
  install.packages(i,dependencies=T);library(i,character.only=T)}};rm(x,i)
#--------------------------------------------------------------------
ifname<-"irisAll.csv"
#-----------------------------------------------------------
alldata<-read.csv(ifname,row.names=1,header=T,as.is=TRUE)
#[1]-Assessment of training data ---------------------------------------
results.dtr<-train(Species~.,
                  data=alldata,
                  method='rpart',
                  trControl=trainControl(method="LOOCV")
                  )
results.dtr
#summary(results.dtr)
names(results.dtr)
plot(results.dtr$finalModel,margin=0.3)
text(results.dtr$finalModel,use.n=T,cex=1.0)
results.dtr$finalModel
confusionMatrix(data=predict(results.dtr,alldata),as.factor(alldata$Species))
#[2]-store output data as file ------------------------------------
predData<-predict(results.dtr,alldata)
Fdata<-data.frame(alldata[,5],predData)
colnames(Fdata)<-c("Org","DTR")
write.csv(Fdata,file="PredDTR.csv")