Index of /examples/r/examples/io_append

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory   -  
[TXT]io_better.R 2014-03-14 23:51 1.9K 
[TXT]io_inefficient.R 2014-03-15 00:34 1.9K 

Appending results to single or multiple files one line at a time


This directory contains two R scripts:
io_inefficient.R script contains an example of inefficient way to save the results in 3 output files.
io_better.R script provides a better approach.

When cat, write, write.table and sink are used for appending to the existing file with argument file defined as a character string, the output file is opened for writing, modified and closed again at the end of the function call. If you need to repeatedly write to the same file, it is more efficient to open a connection to the file and pass this connection to the write statement, closing the connection after the last write statement.
See Output to connection (CRAN manual) for more details.

Interactive execution:

Each script can be executed using source() funcion inside R enviroment.
They can also be executed using Rscript command:
[scc1 ] Rscript io_better.R

Contact Information:

help@scc.bu.edu

Note: Research Computing Services (RCS) example programs are provided "as is" without any warranty of any kind. The user assumes the entire risk of quality, performance, and repair of any defects. You are encouraged to copy and modify any of the given examples for your own use.