[R] Perl "cut" equivalent in R

Duncan Murdoch murdoch.duncan at gmail.com
Fri Dec 10 19:09:10 CET 2010


On 10/12/2010 12:05 PM, William Dunlap wrote:
> >  -----Original Message-----
> >  From: r-help-bounces at r-project.org
> >  [mailto:r-help-bounces at r-project.org] On Behalf Of Martin Maechler
> >  Sent: Friday, December 10, 2010 8:54 AM
> >  To: Steve Lianoglou
> >  Cc: r-help at r-project.org
> >  Subject: Re: [R] Perl "cut" equivalent in R
> >
> >  >>>>>  "SL" == Steve Lianoglou<mailinglist.honeypot at gmail.com>
> >  >>>>>      on Mon, 6 Dec 2010 14:21:59 -0500 writes:
> >
> >      >>>  if(FALSE) { stuff your don't want executed          }
> >      >>>
> >      >>
> >  >  Switching a block of code off/on with editing a single
> >      >>  character may be done using 0/1 instead of FALSE/TRUE.
> >
> >      SL>  Or even F/T
> >
> >  Bad Idea:
> >
> >    F<- 1
>
> Another approach is to write the following function
>      dontRun<- function(expr) {}
> and replace that
>      if (FALSE) { ... questionable code ... }
> with
>      dontRun( {... questionable code ...} )
> If you do want the questionable code to run,
> redefine dontRun to be
>      dontRun<- function(expr) { expr }
>
> You can use this approach to put assertion tests
> into your code that only get run when the assertion
> function is defined to do something.


That's a nice idea!

Duncan Murdoch



More information about the R-help mailing list