[R] How to comment in R

baptiste auguie ba208 at exeter.ac.uk
Wed Feb 11 15:10:46 CET 2009


On 11 Feb 2009, at 13:41, Gustaf Rydevik wrote:

> On Wed, Feb 11, 2009 at 2:15 PM, baptiste auguie  
> <ba208 at exeter.ac.uk> wrote:
>> A somewhat twisted approach that has not been mentioned is to  
>> consider
>> everything a comment unless it is enclosed in special tags, as done  
>> in the
>> brew package,
>>
>> for example,
>>
>>
>>> brew(textConnection(
>>> "You won't see this R output, but it will run. <% foo <- 'bar' %>
>>> Now foo is <%=foo%> and today is <%=format(Sys.time(),'%B %d, %Y') 
>>> %>."
>>> ) )
>>
>> gives,
>>
>>> You won't see this R output, but it will run.
>>> Now foo is bar and today is February 11, 2009.
>>
>>
>> I'd love to see an editor with a "brew" mode that acts as a  
>> notebook: you
>> type in your text in whatever language without worrying about the  
>> syntax (R
>> syntax, i mean!), and when you want to do a calculation you just  
>> enclose it
>> in such tags that behave like an inverted block comment.
>>
>> Just a thought,
>>
>> baptiste
>>
>
>
> Isn't this almost exactly what ?Sweave does? (and  odfWeave).
> Granted, you have to deal with latex code to get nice output, but
> latex is a GoodThing (tm).
>


LaTeX is indeed very good for some situations, but considering valid  
latex code to be a convenient format for mere code comments would be  
quite a stretch if you ask me. I like the light and flexible approach  
of brew(), it can in fact output latex code if if you feel like it. Or  
html. Or markdown. Or ...

baptiste


> /Gustaf
>
> --
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag




More information about the R-help mailing list