[R] Template Engine Package for R?

Jeffrey Horner jeff.horner at vanderbilt.edu
Thu Apr 9 14:36:17 CEST 2009


Jason Rupert wrote:
> Related to the posting below, by any chance is there a "Template Engine" package for R? 

Indeed there is. It's called brew:

http://cran.r-project.org/web/packages/brew/index.html

Jeff

> 
> http://en.wikipedia.org/wiki/Template_processor
> 
> This may make this type of editing much easier?  Maybe...
> 
> Thanks again.
> 
> 
> 
> --- On Wed, 4/8/09, Jason Rupert <jasonkrupert at yahoo.com> wrote:
> 
>> From: Jason Rupert <jasonkrupert at yahoo.com>
>> Subject: Re: [R] R File I/O Capability - Writing output to specific lines of existing file
>> To: "jim holtman" <jholtman at gmail.com>
>> Cc: R-help at r-project.org
>> Date: Wednesday, April 8, 2009, 11:26 PM
>> Darn.
>>
>> I was afraid of this.  Always kind of weak when it comes to
>> file I/O approaches, so I guess I will have to stretch and
>> try to put something together.   
>>
>> Yeah.  The input flat text file is about 600 lines long.  I
>> will be replacing about 200.  I already have the template
>> for those 200 lines.  I guess I will just need to read down
>> to line 400 and replace until line 600.  
>>
>> Thanks again for all the insights regarding this. 
>>
>>
>>
>> --- On Wed, 4/8/09, jim holtman <jholtman at gmail.com>
>> wrote:
>>
>>> From: jim holtman <jholtman at gmail.com>
>>> Subject: Re: [R] R File I/O Capability - Writing
>> output to specific lines of  existing file
>>> To: jasonkrupert at yahoo.com
>>> Cc: R-help at r-project.org
>>> Date: Wednesday, April 8, 2009, 8:02 PM
>>> 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.


-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner




More information about the R-help mailing list