[R] How to comment in R

bartjoosen bartjoosen at hotmail.com
Wed Feb 11 12:02:31 CET 2009


If you don't want to use the # before each comment line, you could try
something like defining a function which returns nothing and then type some
text after calling the function:

comm <- function(x) {invisible()}

comm("This is just a test,
trying to comment without typing the hashes"
)

But I don't recommend this kind of approach, what's wrong with the default
hashes everybody use?

Bart



Wacek Kusnierczyk wrote:
> 
>> Hi Mihai,
>>
>> one (very bad style) way would be
>>
>> if (FALSE) {
>>    comment
>>    comment
>>    comment
>> }
>>
> 
> this works only if the enclosed text is syntactically valid r code.  that
> is, you can't have multiline free text comments done this way, neither can
> you temporarily comment out unfinished and unparsable code.
> 
> an extension to the parser that would accept multiline start-end comment
> tags, be it c-style /* */, perl-style =pod =cut, whatever, should be
> fairly  trivial to implement.  (the perl-style pod markup is particularly
> easy to parse, because it suffices to recognize '^=' on a line, no
> advanced pattern-matching needed.)
> 
> somewhat surprising there is no such functionality there in r (or is there
> any?), it would be quite convenient.
> 
> vQ
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-comment-in-R-tp21950370p21952539.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list