Skip to content
Prev 317336 / 398502 Next

FORMAT EDITING

You say, "? use the R output file in Fortran ? "
I guess that means that R is writing an output file which will then be
used as an input file for a fortran program.

In that case, you need to go back to how R is writing the output file,
find out why it is writing blank lines, and correct it. As far as leading
spaces and other formatting aspects, you can create any output format you
want using functions like cat(), formatC(), sprintf() and others.

Otherwise, if what you want R to do is read the input file, remove the
empty lines, and write a new output file, this seems to do it (on my
system):

  tmp <- scan('des.txt', what='', sep='\n')
  cat( paste(tmp,collapse='\n') , file='des.new')

Because as far as I can tell from your attached text file, the input and
output are identical except for the blank lines.


You might also be dealing with issues of different operating systems
having different conventions for new lines (DOS vs unix, etc). emacs tells
me you input data is DOS, meaning new lines are indicated (if I remember
correctly) by a sequence of two characters, "carriage return" followed by
"line feed", but the fortran code may be expecting a single character.

-Don