[R] Multi-line comments?

Paul Hiemstra p.hiemstra at geo.uu.nl
Wed Jul 22 17:12:08 CEST 2009


Mark Knecht wrote:
> Hi,
>    I looked in the language definition and was surprised. Is there
> really no multi-line/block comment defined in R?
>
>    I wanted to comment out 20 lines that I'm moving to a function but
> didn't want to delete them. Is there no defined way to get around
> using a # on each of the 20 lines?
>
> Thanks,
> Mark
>
> ______________________________________________
> 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.
>   
Hi,

This issue has come up before, and as far as I know there is no 
multiline comment. However, there are a few ways of commenting out 
larges pieces of code.

- Use a good text editor, Kate (KDE) allows you to select the 20 lines 
and press Ctrl-D to comment them all at once.
- Use a setup like:
if(FALSE) {
line1
...
line20
}

And set FALSE to TRUE if you want to let the code be executed.

These are probably not the only ones, but this is what I could think of 
right now.

cheers and good luck,
Paul

-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul




More information about the R-help mailing list