R File I/O Capability - Writing output to specific lines of existing file
You can always read in the initialization file, make the updates to it and then write it back out. If it is a text file, it would be very hard to write into the middle of it since there is no structure to the file. You can read it in as a table (read.table) or just as lines (readLines) and the make any changes you want. You can use regular expressions if you want to put something in the middle of one of the lines you have read in.
On Wed, Apr 8, 2009 at 10:13 AM, Jason Rupert <jasonkrupert at yahoo.com> wrote:
Currently I am using the R "write" command to output results to a *.txt file and then copying those results into an initialization file. ?In an attempt to continue to automate the process I would like to have R write to the location in the existing initialization file, instead of me copying the data over. By any chance are there any R commands to help? Primarily, I will be using Windows, and the initialization file is a simple flat file, i.e. not XML or binary. I looked at: (a) http://www.stat.ucl.ac.be/ISdidactique/Rhelp/library/R.io/html/00Index.html (b) http://search.r-project.org/cgi-bin/namazu.cgi?query=File+I%2FO&max=100&result=normal&sort=score&idxname=functions&idxname=Rhelp08 But, this did not appear to provide the functionality to edit an existing file by adding information to the middle of the file. Thank you again for any help and insight.
______________________________________________ R-help at 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.
Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?