[R] Open a file to APPEND

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Sep 12 08:10:24 CEST 2011


On Mon, Sep 12, 2011 at 1:51 AM, Noah Silverman <noahsilverman at ucla.edu> wrote:
> Hi,
> I want to store the output of my program to a file.  However, With subsequent runs of  my code, I'd like to append to the same log file.
> Currently, I'm using:
> outfile <- file("log.txt", open="w")
> cat(results, file=outfile)
> This works, but will overwrite the log file each time.
> Is there a way to open a file and have R append to the end?

Indeed there is.

Reread ?cat again ... in particular, look at the arguments it takes a
bit more closely.


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the R-help mailing list