Hello, I'm producing text from my data.frame using cat function. I would like to use for loop to export each column in my data.frame into separate text files. Here is the example code
r <- t(Indometh) for (i in 1:ncol(r)) { cat("Some text,", "\n") cat("\n") cat("More text, More text, More text") cat("\n") cat(paste(names(r[!is.na(r[,i]), i]), ":", as.character(r[!is.na(r[,i]), i]), "\n")) cat("-----------------------------------", "\n") } So, each of these columns (results between --- and ---) should be exported into separate text files e.g. file1.txt, file2.txt, file3.txt etc. Any ideas? Thanks, Lauri ______________________________________________ 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.