[R] Block comments in R?

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Oct 5 11:29:18 CEST 2006



Robin Hankin wrote:
> 
> On 5 Oct 2006, at 10:05, Uwe Ligges wrote:
> 
>>
>>
>> Wee-Jin Goh wrote:
>>> Hello list,
>>>
>>> Is there any way to perform a block comment in R? In C++, anything in
>>> between a /* and */ is considered a comment, and it allows
>>> programmers to comment out chunks of code for testing and debugging.
>>> Is there such a feature in R?
>>
>>
>> This has frequently been asked on the list. Try to google for it. You
>> will find answers like
>>
>> if(FALSE){"
>>      code block
>>      commented
>> "}
>>
>>
> 
> 
> That method doesn't work for me:
> 
> if(FALSE){"
> 
> if(1<2)
>   print("1<2")
> else
>   print("1>2")
> 
> "}


Use an editor that comments out a whole block which is what I do all the 
time, e.g. use Tinn-R, Emacs or WinEdt, to mention just a few of them.

Or you can go ahead and use

if(FALSE){

if(1<2)
   print("1<2")
else
   print("1>2")

}


or

if(FALSE){'

if(1<2)
   print("1<2")
else
   print("1>2")

'}


Uwe


> 
> returns an error.  How would I comment out that block of (incorrect) code?
> 
> 
> 
> 
> 
> 
> 
>> or "use a good editor that supports commenting and uncommenting blocks".
>>
>>
>> Uwe Ligges
>>
>>
> 
> -- 
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>  tel  023-8059-7743
> 
> 
> 
>



More information about the R-help mailing list