Dear all, I'm trying to write tabular data to a text file, these data will be the input of a Fortran program. The format needs to be "(i7,2x,7(e15.7,2x))". I have not been able to find a clean way of producing this output with write.table. I searched for a "write.fortran" function similar to read.fortran() in package utils but I couldn't find any. Below is a small example of what I'm trying to achieve, but it's clearly suboptimal in many ways,
m <- cbind(seq(1, 5), matrix(rnorm(7*5), ncol=7)) do.call(cat, c(lapply(seq(1, nrow(m)), function(ii){ x <- m[ii, ] sprintf("%i %15.7e %15.7e %15.7e %15.7e %15.7e %15.7e %15.7e \n", ii , x[1],x[2],x[3],x[4],x[5],x[6],x[7]) }), list(sep=""))) Best regards, baptiste sessionInfo() R version 2.10.1 RC (2009-12-06 r50690) i386-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] tools stats graphics grDevices utils datasets methods base other attached packages: [1] foreign_0.8-38 ______________________________________________ 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.