[R] Perl "cut" equivalent in R

William Dunlap wdunlap at tibco.com
Fri Dec 10 18:05:24 CET 2010


> -----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.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
> ______________________________________________
> 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.
> 



More information about the R-help mailing list