[R] Is there a construct for conditional comment?

Stavros Macrakis macrakis at alum.mit.edu
Fri Aug 21 17:48:30 CEST 2009


On Thu, Aug 20, 2009 at 1:27 PM, David Winsemius<dwinsemius at comcast.net> wrote:
...
> But an extremely simple modification "succeeds":
>
>  if ( 0 ) {"
>  commented with zero
>  "} else {"
>  commented with one
>  "}
>
> Returns:
> [1] "\ncommented with one\n"

Yes, but of course that executes neither one nor the other.  This works, though:

eval(parse(textConnection(if (FALSE) "
  syntactically //// incorrect ' code must not use double-quotes, though
" else "
 print('this is a test')
")))

though it is horribly ugly, so I second the suggestion to do this in
your text editor if you must do it at all.

          -s




More information about the R-help mailing list