Hi there My script at each iteration produces a .dat file which I save in a directory with write.table. Then I need to read each line of this file and create a directory for each line and put elements of that row in that directory. I do it with the following script which I have inserted somewhere between my outer iteration loop, it works fine for the first iteration, but the problem is that it does nothing at next iterations. How can I solve this problem, is there anything wrong with my code? Thanks in advance for your help. write.table(X, file = "model.dat", append = FALSE, sep = " ", eol = "\n", na = "NA", dec = ".", row.names = FALSE, col.names = FALSE, qmethod = c("escape", "double")) mother<-getwd() count <- 0; con<- file("model.dat", open="r")
while (length(line) > 0) { line<-readLines(con,n=1) count <- count +1 cat("read row no", count, ",\n", sep=""); print(line) foldername <- paste("Iteration",c, "ant", count) dir.create (foldername) setwd(foldername) write.table(line, file = "params.in", append = FALSE, sep = " ", eol = "\n", na = "NA", dec = ".", row.names = FALSE, col.names = FALSE, qmethod = c("escape", "double")) #system(run_misf_calc.py) setwd(mother) } close(con) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.