[R] How to comment in R
baptiste auguie
ba208 at exeter.ac.uk
Wed Feb 11 14:15:39 CET 2009
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
On 11 Feb 2009, at 12:17, Gabor Grothendieck wrote:
> I think you need to revisit the suggestion of how to use Tinn-R
> to ensure you are doing it properly. If its R code then if(FALSE)
> has already been mentioned as an alternative and another possibility
> is just enclose it in double quotes (or if there are double quotes in
> the passage then in single quotes):
>
> f <- function(x) {
> " here
> are some comments of
> mine"
> x+1
> }
>
> On Wed, Feb 11, 2009 at 3:32 AM, <Mihai.Mirauta at bafin.de> wrote:
>>
>> Hi everybody,
>>
>> I use for the moment "#" at the begining of each line for comments.
>>
>> Is there any possibility to comment more than one line, like
>> something which shows the beggingng and the end of the comment? Or
>> is there a possibility to comment only a part of a line?
>>
>> Thanks,
>>
>> Mihai
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>
> ______________________________________________
> 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.
_____________________________
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