[R] supressing linefeed at end of file
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Mar 20 13:14:37 CET 2001
On Thu, 15 Mar 2001, Thomas Petzoldt wrote:
> Hello,
>
> I want to do simulations with an external simulation model. For this
> purpose I wrote a R-script which makes the pre- and post-processing of
> the data (generate scenarios, analyze results).
>
> The R-script writes the input file for the simulation with e.g.
>
> write(x, file="test.dat", ncolumns=10)
>
> The problem is, however, that this command (and even constructions with
> cat) will add a linefeed after the last line of data. Unfortunately the
You only get a linefeed if you ask for it. Look at the test code for
readLines in reg-IO.R to see how to avoid it: you *can* do it with cat()
on all platforms.
> simulation program however is very stupid, as it does not allow a
> linefeed after the last line. It interprets the linefeed after the last
> line of data as an empty line and will fail.
>
> I did not find anything concerning this problem in the R-data.pdf
> manual.
Nope. It's a *very* unusual requirement.
A first solution was to use grep to eliminate the empty line,
> but the R-script should run not only on linux, but also on windows
> machines without cygwin, perl or similar. Is there a simple "R only"
> solution? Otherwise I should write a special C program.
>
> Thanks in advance!
>
> Thomas Petzoldt
>
>
> --
> Dr. Thomas Petzoldt
> Dresden University of Technology
> Institute for Hydrobiology
> 01062 Dresden
> mailto:petzoldt at rcs.urz.tu-dresden.de
> http://www.tu-dresden.de/fghhihb/
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list