##splits samples into Training set, Test set and Validation set in different ways. #for c=1,2,3,4 ## separates numbers in SequenceType strig variable ## Paste the folder with data DefectiveSamples<-read.csv("DescriptiveAnalysisDefectiveST.csv", sep=";") ApplicationNames<-DefectiveSamples$Application ## convert values in faulty and non faulty, removeUsernumber, and move Failurenumber to the end m<-length(ApplicationNames) for(i in 1:4){ directory<-paste("data\\c",i, sep="") D<- dir(directory, full.names=TRUE) H<- dir(directory, full.names=FALSE) for(j in 1:m){ data <- read.csv(D[j], header=TRUE, sep=",") n<-nrow(data) ##creates a vector with one "2" and all "1" for replication c<-c(1:n) d<-c-c+1 d[1]<-2 dataTemp<-rep(data$SequenceType,d) file<-paste("data\\c",i,"\\Temp_",H[j], sep="") write.table(dataTemp, row.names=FALSE,col.names=FALSE,append=FALSE,file=file, sep=",",quote=FALSE) add<-read.csv(file,header=TRUE,sep=",") k<-ncol(add) colnames(add)<-paste("m",c(1:k), sep="") data1<-data[,-c(1)] merge<-cbind(add, data1) oldFile<-paste("C:\\Users\\brusso\\Desktop\\Pedrycz\\data\\c",i,"\\",H[j], sep="") finalFile<-paste("C:\\Users\\brusso\\Desktop\\Pedrycz\\data\\c",i,"\\New_",H[j], sep="") write.table(merge, row.names=FALSE,col.names=TRUE,append=FALSE,file=finalFile, sep=",",quote=FALSE) file.remove(file) file.remove(oldFile) } } for(i in 1:4){ for(j in 1:m){ directory<-paste("data\\c",i, sep="") D<- dir(directory, full.names=TRUE) H<- dir(directory, full.names=FALSE) file<-paste("data\\c",i,"\\Temp_",H[j], sep="") oldFile<-paste("data\\c",i,"\\",H[j], sep="") file.remove(file) file.remove(oldFile) } }