[R] How to comment in R

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Feb 11 13:05:40 CET 2009


2009/2/11  <Mihai.Mirauta at bafin.de>:
>
> 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?
>

 Searching the mailing list archives for 'block comment' provides
another hairy solution from Philippe Grosjean, which involves
redefining '!' for character arguments:

http://tolstoy.newcastle.edu.au/R/e2/help/06/10/2168.html

 I don't know if R-core would consider putting block comments (maybe
with /* */ syntax) into R. There are problems with block comments
since they have very non-local effects - once you've scrolled down a
bit, how can you tell if code is commented or not? And modern editors
are capable of commenting out large blocks with the '#' character, so
maybe there's no demand. Python doesn't have them (which is my
benchmark for language qualities at the moment):

http://www.velocityreviews.com/forums/t355236-why-no-block-comments-in-python.html

 On reflection, block comments in R gets a -1 from me.


Barry




More information about the R-help mailing list